From: Rusty Russell <rusty@rustcorp.com.au>
To: Daniel Mierswa <impulze@impulze.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC] Re: Parsing kernel parameters and escaping "
Date: Sun, 12 Jul 2009 19:11:57 +0930 [thread overview]
Message-ID: <200907121911.58333.rusty@rustcorp.com.au> (raw)
In-Reply-To: <4A529CBA.4030408@impulze.org>
On Tue, 7 Jul 2009 10:24:18 am Daniel Mierswa wrote:
> There was a limitation for kernel parameters with regards to quoting. It
> wasn't possible to escape quotes or use quotes to form space-filled
> values inside parameters.
Hi Daniel!
Yes, we've never had the ability to escape quotes (and you're the first to
ask), so when I wrote this code I kept it simple. You can have spaced out
values, but you need to quote the whole thing "param=some value with spaces".
We have to be careful not to break existing cmdlines tho: I don't know
if anyone uses \ currently, but simply interpreting \" is probably safe.
> +/* handle quotes in tokens (parameter and values)
> + * '" foo bar "' => ' foo bar '
> + * '" foo \" "' => ' foo " '
> + */
> +static void add_token(char ** token, char * args)
add_token is a weird name for this. It actually mangles the argument, and it
really should return the char *.
How about something like:
static unsigned int pull_token(char *args, const char *delim)
Which unescapes and returns the length of the token, or zero if it simply
swallowed delimeters? Assuming it always nul terminates, then the caller can
simply do:
while (*args) {
len = pull_token(args, " \t\n=");
if (!len)
/* Leading whitespace. */
continue;
*param = args;
args += len;
if (args[0] != '=') {
*val = NULL;
} else {
len = pull_token(args+1, " \t\n");
*val = args;
args += len;
}
Important cases to test are:
x param = "x", val = NULL
x= param = "x", val = ""
x=y=1 param = "x", val = "y=1"
Plus all variations where x and y contain quotes.
Cheers,
Rusty.
next prev parent reply other threads:[~2009-07-12 9:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-05 13:54 Parsing kernel parameters and escaping " Daniel Mierswa
2009-07-06 23:03 ` [RFC] " Daniel Mierswa
2009-07-06 23:05 ` Daniel Mierswa
2009-07-07 0:54 ` Daniel Mierswa
2009-07-12 9:41 ` Rusty Russell [this message]
2009-07-12 17:59 ` Daniel Mierswa
2009-07-12 23:57 ` Rusty Russell
2009-07-13 2:49 ` Daniel Mierswa
2009-07-14 2:49 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200907121911.58333.rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=impulze@impulze.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.