Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MFEws-0003Pf-Qg for mharc-grub-devel@gnu.org; Fri, 12 Jun 2009 18:10:10 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MFEwr-0003NZ-8I for grub-devel@gnu.org; Fri, 12 Jun 2009 18:10:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MFEwm-0003M8-32 for grub-devel@gnu.org; Fri, 12 Jun 2009 18:10:08 -0400 Received: from [199.232.76.173] (port=33534 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MFEwm-0003Ly-0D for grub-devel@gnu.org; Fri, 12 Jun 2009 18:10:04 -0400 Received: from c60.cesmail.net ([216.154.195.49]:65264) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1MFEwl-0007z1-Ev for grub-devel@gnu.org; Fri, 12 Jun 2009 18:10:03 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 12 Jun 2009 18:10:01 -0400 Received: from [192.168.0.22] (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by smtprelay2.cesmail.net (Postfix) with ESMTPSA id E7CE534C6D for ; Fri, 12 Jun 2009 18:14:42 -0400 (EDT) From: Pavel Roskin To: The development of GRUB 2 In-Reply-To: References: Content-Type: multipart/mixed; boundary="=-en+G0+a0zrtVcwrIuDmx" Date: Fri, 12 Jun 2009 18:10:00 -0400 Message-Id: <1244844600.15336.11.camel@mj> Mime-Version: 1.0 X-Mailer: Evolution 2.26.2 (2.26.2-1.fc11) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [PATCH] more scripting fixes X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jun 2009 22:10:09 -0000 --=-en+G0+a0zrtVcwrIuDmx Content-Type: text/plain Content-Transfer-Encoding: 7bit On Wed, 2009-06-10 at 12:52 +0200, Vladimir 'phcoder' Serbinenko wrote: > + Fix handling of string like \"hello\" and "a > + b" > + > + * script/sh/lexer.c (check_textstate): accept > GRUB_PARSER_STATE_ESC > + (grub_script_yylex): fix parsing of quoting, escaping and > newline I needed to tweak the patch and remove a trivial chunk from it to make it apply to the current sources. The adjusted patch is attached. ChangeLog entries should not be part of the patch. I confirm that the patch doesn't introduce any compiler warnings. The patch does fix what it claims to fix. But something is still wrong: grub:sh > echo "a\"b"" a\b grub:sh > echo "a\"b''c a\bc It looks like \" cancels quoting for the subsequent characters, but it shouldn't. -- Regards, Pavel Roskin --=-en+G0+a0zrtVcwrIuDmx Content-Disposition: attachment; filename="02-lexer.patch" Content-Type: text/x-patch; name="02-lexer.patch"; charset="us-ascii" Content-Transfer-Encoding: 7bit Fix handling of strings like \"hello\" and newlines in strings From: Vladimir 'phcoder' Serbinenko ChangeLog: * script/sh/lexer.c (check_textstate): accept GRUB_PARSER_STATE_ESC (grub_script_yylex): fix parsing of quoting, escaping and newline --- script/sh/lexer.c | 22 +++++++++++++++++----- 1 files changed, 17 insertions(+), 5 deletions(-) diff --git a/script/sh/lexer.c b/script/sh/lexer.c index aa8ac35..f8f1eaa 100644 --- a/script/sh/lexer.c +++ b/script/sh/lexer.c @@ -39,6 +39,7 @@ static int check_textstate (grub_parser_state_t state) { return (state == GRUB_PARSER_STATE_TEXT + || state == GRUB_PARSER_STATE_ESC || state == GRUB_PARSER_STATE_QUOTE || state == GRUB_PARSER_STATE_DQUOTE); } @@ -155,18 +156,20 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate) return token; } - for (;! state->done && (*state->script || firstrun); firstrun = 0) + for (;! state->done; firstrun = 0) { if (! *state->script) { /* Check if more tokens are requested by the parser. */ if (((state->refs && ! parsestate->err) - || state->state == GRUB_PARSER_STATE_ESC) + || state->state == GRUB_PARSER_STATE_ESC + || state->state == GRUB_PARSER_STATE_QUOTE + || state->state == GRUB_PARSER_STATE_DQUOTE) && state->getline) { int doexit = 0; - while (!state->script || ! grub_strlen (state->script)) + while (! state->script || ! *state->script) { grub_free (state->newscript); state->newscript = 0; @@ -182,11 +185,18 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate) break; grub_dprintf ("scripting", "token=`\\n'\n"); recordchar (state, '\n'); - if (state->state != GRUB_PARSER_STATE_ESC) + if (state->state != GRUB_PARSER_STATE_ESC + && state->state != GRUB_PARSER_STATE_DQUOTE + && state->state != GRUB_PARSER_STATE_QUOTE) { state->tokenonhold = '\n'; break; } + if (state->state == GRUB_PARSER_STATE_DQUOTE + || state->state == GRUB_PARSER_STATE_QUOTE) + yylval->arg = grub_script_arg_add (parsestate, yylval->arg, + GRUB_SCRIPT_ARG_TYPE_STR, + "\n"); } else { @@ -270,7 +280,9 @@ grub_script_yylex (union YYSTYPE *yylval, struct grub_parser_param *parsestate) when a special token was found. It will be recognized next time when this function is called. */ if (newstate == GRUB_PARSER_STATE_TEXT - && state->state != GRUB_PARSER_STATE_ESC) + && state->state != GRUB_PARSER_STATE_ESC + && state->state != GRUB_PARSER_STATE_QUOTE + && state->state != GRUB_PARSER_STATE_DQUOTE) { int breakout = 0; --=-en+G0+a0zrtVcwrIuDmx--