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 <sam@mendozajonas.com>
WORD [^{}|&$;<> \t\n'"#]+
DELIM [ \t]+
WORD [^{}|&$;<> \t\n'"#]+
DELIM [ \t]+
VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#])
%%
VARNAME ([[:alpha:]][_[:alnum:]]*|[0-9]|[\?@\*#])
%%
"until" return TOKEN_UTIL;
"while" return TOKEN_WHILE;
"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);
/* anything that's not a metachar: return as a plain word */
{WORD} {
yylval->word = create_word_text(yyget_extra(yyscanner), yytext);
menuentry "test.9" {
linux /vmlinux
}
menuentry "test.9" {
linux /vmlinux
}
+menuentry "" {
+ linux /vmlinux
+ }
#endif
void run_test(struct parser_test *test)
#endif
void run_test(struct parser_test *test)
test_run_parser(test, "grub2");
test_run_parser(test, "grub2");
- check_boot_option_count(test->ctx, 10);
+ check_boot_option_count(test->ctx, 11);
for (i = 0; i < 8; i++) {
opt = get_boot_option(test->ctx, i);
str[5] = i + '0';
for (i = 0; i < 8; i++) {
opt = get_boot_option(test->ctx, i);
str[5] = i + '0';