From a1ec0710b6abad1a932d09f23010e3eb4662e8c9 Mon Sep 17 00:00:00 2001 From: Sam Mendoza-Jonas Date: Tue, 12 Jan 2016 15:58:13 +1100 Subject: discover/grub: Fix handling of empty strings If "" or '' are used in a statement to omit a word, we must still return a TOKEN_WORD for an empty string. In particular this fixes an issue where Petitboot would fail to parse the grub.cfg included in the Debian 8.2 install image, which includes a menuentry statement with an empty name. Signed-off-by: Sam Mendoza-Jonas --- discover/grub2/grub2-lexer.l | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'discover/grub2') diff --git a/discover/grub2/grub2-lexer.l b/discover/grub2/grub2-lexer.l index 52575e3..81dc5fe 100644 --- a/discover/grub2/grub2-lexer.l +++ b/discover/grub2/grub2-lexer.l @@ -23,6 +23,7 @@ void yyerror(struct grub2_parser *parser, const char *fmt, ...); WORD [^{}|&$;<> \t\n'"#]+ DELIM [ \t]+ +BLANK ["]{2}|[']{2} VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#]) %% @@ -52,6 +53,12 @@ VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#]) "until" return TOKEN_UTIL; "while" return TOKEN_WHILE; + /* ignore quoted empty strings */ +{BLANK} { + yylval->word = create_word_text(yyget_extra(yyscanner), ""); + yyget_extra(yyscanner)->inter_word = true; + return TOKEN_WORD; + } /* anything that's not a metachar: return as a plain word */ {WORD} { yylval->word = create_word_text(yyget_extra(yyscanner), yytext); -- cgit v1.2.1