Skip to content

Commit

Permalink
fix(sexp): Accept another digit after an \x.. or \... escape sequence…
Browse files Browse the repository at this point in the history
… in strings

The two cases that this modifies are meant to catch the issue of
"unterminated ... escape sequences" but, due to the use of '*', they
also caught the cases where the escape sequence was followed by another
digit

Signed-off-by: Samuel Hym <samuel.hym@rustyne.lautre.net>
  • Loading branch information
shym committed Dec 15, 2022
1 parent 240d365 commit 168af58
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dune_sexp/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,15 @@ and escape_sequence = parse
| digit digit digit
{ error lexbuf "escape sequence in quoted string out of range" ~delta:(-1);
}
| digit*
| digit digit?
{ error lexbuf "unterminated decimal escape sequence" ~delta:(-1);
}
| 'x' (hexdigit as c1) (hexdigit as c2)
{ let v = eval_hex_escape c1 c2 in
Template.Buffer.add_text_c (Char.chr v);
Other
}
| 'x' hexdigit*
| 'x' hexdigit?
{ error lexbuf "unterminated hexadecimal escape sequence" ~delta:(-1);
}
| _
Expand Down

0 comments on commit 168af58

Please sign in to comment.