Skip to content

Commit 0c46ac0

Browse files
PavolVicanrkrejci
authored andcommitted
parser yang BUGFIX forbidden comment sequences in string
This sequence characters are forbidden in strings, which are not enclosed within double or single quotes.
1 parent 7b9fd03 commit 0c46ac0

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/parser_yang_lex.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,6 +2616,23 @@ YY_RULE_SETUP
26162616
while (i < yyleng) {
26172617
if (!(yytext[i] & 0x80)) {
26182618
/* one byte character */
2619+
if (yytext[i] == '/') {
2620+
if (yytext[i + 1] == '/') {
2621+
yyless(i);
2622+
return STRINGS;
2623+
} else if (yytext[i + 1] == '*') {
2624+
yyless(i);
2625+
return STRINGS;
2626+
}
2627+
} else if (yytext[i] == '*' && yytext[i + 1] == '/') {
2628+
if (!i) {
2629+
yyless(1);
2630+
return ERROR;
2631+
} else {
2632+
yyless(i);
2633+
return STRINGS;
2634+
}
2635+
}
26192636
++i;
26202637
} else if (!(yytext[i] & 0x20)) {
26212638
/* two bytes character */

src/yang.l

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,23 @@ U4 [\xf0][\x90-\xbf]{U}{U}|[\xf1-\xf3]{U}{U}{U}|[\xf4][\x80-\x8f]{U}{U}
230230
while (i < yyleng) {
231231
if (!(yytext[i] & 0x80)) {
232232
/* one byte character */
233+
if (yytext[i] == '/') {
234+
if (yytext[i + 1] == '/') {
235+
yyless(i);
236+
return STRINGS;
237+
} else if (yytext[i + 1] == '*') {
238+
yyless(i);
239+
return STRINGS;
240+
}
241+
} else if (yytext[i] == '*' && yytext[i + 1] == '/') {
242+
if (!i) {
243+
yyless(1);
244+
return ERROR;
245+
} else {
246+
yyless(i);
247+
return STRINGS;
248+
}
249+
}
233250
++i;
234251
} else if (!(yytext[i] & 0x20)) {
235252
/* two bytes character */

0 commit comments

Comments
 (0)