]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: arg: make make_arg_list() support quotes in arguments
authorWilly Tarreau <w@1wt.eu>
Fri, 14 Feb 2020 12:37:20 +0000 (13:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 14 Feb 2020 18:02:06 +0000 (19:02 +0100)
commitef21facd9953e44e0410aefb865963dcb66020b9
tree433dbe3564bd662c988c907b0cbf0e2c95ce3bc1
parent338c670745632fede68b501552260bfbd0d2126f
MEDIUM: arg: make make_arg_list() support quotes in arguments

Now it becomes possible to reuse the quotes within arguments, allowing
the parser to distinguish a ',' or ')' that is part of the value from
one which delimits the argument. In addition, ',' and ')' may be escaped
using a backslash. However, it is also important to keep in mind that
just like in shell, quotes are first resolved by the word tokenizer, so
in order to pass quotes that are visible to the argument parser, a second
level is needed, either using backslash escaping, or by using an alternate
type.

For example, it's possible to write this to append a comma:

     http-request add-header paren-comma-paren "%[str('(--,--)')]"

or this:

     http-request add-header paren-comma-paren '%[str("(--,--)")]'

or this:

     http-request add-header paren-comma-paren %[str(\'(--,--)\')]

or this:

     http-request add-header paren-comma-paren %[str(\"(--,--)\")]

or this:

     http-request add-header paren-comma-paren %[str(\"(\"--\',\'--\")\")]

Note that due to the wide use of '\' in front of parenthesis in regex,
the backslash character will purposely *not* escape parenthesis, so that
'\)' placed in quotes is passed verbatim to a regex engine.
doc/configuration.txt
src/arg.c