Re: [PATCH 1/2] lib/string_helpers: add ESCAPE_BACKSLASH flag to string_escape_mem()
From: Andy Shevchenko
Date: Mon Sep 28 2026 - 10:41:07 EST
On Mon, Sep 28, 2026 at 3:59 PM Ilpo Järvinen
<ilpo.jarvinen@xxxxxxxxxxxxxxx> wrote:
> On Mon, 28 Sep 2026, Andy Shevchenko wrote:
> > On Sat, Sep 26, 2026 at 11:57 PM Muhammad Bilal <meatuni001@xxxxxxxxx> wrote:
...
> > > Add ESCAPE_BACKSLASH, which escapes only '\\'. It can be combined with
> > > ESCAPE_SPACE, or used on its own, without pulling in ESCAPE_SPECIAL's
> > > quote and control-character handling.
> >
> > But why? I believe it can be done in the current implementation using
> > the last argument @only (id est use the list of the characters you
> > want to escape).
>
> Ah, that's my fault for suggesting this and not noticing there was way to
> negatively filter them.
No problem, not a big issue :-)
I think here is the list of those 4 characters that we want to escape
should be passed along with ESCAPE_SPACE | ESCAPE_SPECIAL. This will
get exact code behaviour as of today. In current patch 2/2 AFAICS the
additional SPACE-class characters might have also been escaped which
was not in the original implementation (not sure if it's desired
change or not).
--
With Best Regards,
Andy Shevchenko