From: Sascha Hauer <sha@pengutronix.de>
To: Albert Schwarzkopf <a.schwarzkopf@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] scripts: imx: Ignore ';' and '\n' in quotes
Date: Tue, 28 Mar 2023 10:22:16 +0200 [thread overview]
Message-ID: <20230328082216.GJ19113@pengutronix.de> (raw)
In-Reply-To: <20230327084827.1854478-1-a.schwarzkopf@phytec.de>
On Mon, Mar 27, 2023 at 10:48:27AM +0200, Albert Schwarzkopf wrote:
> The current behaviour treats semicolons the same as end of line.
> This breaks when they are found inside quoted strings, as is the
> case for PKCS#11 URIs for example.
>
> Ignore newlines and semicolons in quotes when parsing commands.
>
> Signed-off-by: Albert Schwarzkopf <a.schwarzkopf@phytec.de>
> ---
> scripts/imx/imx.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Applied, thanks
Sascha
>
> diff --git a/scripts/imx/imx.c b/scripts/imx/imx.c
> index 87560ad27d..fac0556308 100644
> --- a/scripts/imx/imx.c
> +++ b/scripts/imx/imx.c
> @@ -675,6 +675,7 @@ static char *readcmd(struct config_data *data, FILE *f)
> static char *buf;
> char *str;
> ssize_t ret;
> + int inquotes = 0;
>
> if (!buf) {
> buf = malloc(4096);
> @@ -689,8 +690,9 @@ static char *readcmd(struct config_data *data, FILE *f)
> ret = fread(str, 1, 1, f);
> if (!ret)
> return strlen(buf) ? buf : NULL;
> -
> - if (*str == '\n' || *str == ';') {
> + if (*str == '"') {
> + inquotes = !inquotes;
> + } else if ((*str == '\n' || *str == ';') && !inquotes) {
> *str = 0;
> return buf;
> }
> --
> 2.40.0
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2023-03-28 8:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 8:48 Albert Schwarzkopf
2023-03-28 8:22 ` Sascha Hauer [this message]
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=20230328082216.GJ19113@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.schwarzkopf@phytec.de \
--cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox