[dm-devel] [PATCH v2 3/5] libmultipath: config parser: Allow '"' in strings

Martin Wilck mwilck at suse.com
Fri Mar 23 17:40:15 UTC 2018


On Fr, 2018-03-23 at 17:59 +0100, Xose Vazquez Perez wrote:
> On 03/08/2018 12:26 AM, Martin Wilck wrote:
> 
> > We have seen model strings lile '2.5" SSD' which can't be parsed
> > by the current config parser. This patch fixes this by allowing
> > '""' to represent a double quote character inside a a string.
> > The above model string could now be entered in the config file like
> > this:
> > 
> > blacklist {
> > 	  vendor SomeCorp
> > 	  product "2.5"" SSD"
> > }
> 
> 
> Could this work in the first place?
> 
>           product "2.5\" SSD"

I'm not sure what you mean. For the current code, the answer is "no".
The parser doesn't treat '\' special in any way. For the parser, the
result of the above is the tuple ['product', '2.5\', 'SSD']. The config
file parser would discard the last tuple element (the cli command
parser takes more than 2 tuple elements, but not the config file
parser). The regexp parser would bail out on the lone backslash in
'2.5\'.

If you meant to say that, instead of using '""', I could have changed
the parser to use '\"' to represent a single double-quote character,
yes, that would have been possible, at the cost of a much bigger and
more error-prone rewrite of the parsing code.

Moreover, I think using '\"' has an addtional disadvantage compared to
'""'. As you know, the values for many options are regular expressions,
and the backslash has special meaning in regexps. Figuring out the
correct number of backslashes for complex regexps is hard anyway, and
if we give '\' special meaning in the option parser, too, we'd treat it
specially on two separate layers, making it even harder for users. The
double-quote character, OTOH, has no special meaning in regexps, so
that the two quoting mechanisms on the two layers are orthogonal.

Regards
Martin

-- 
Dr. Martin Wilck <mwilck at suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)




More information about the dm-devel mailing list