mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[ruby/prism] Fix escape unicode curly inline whitespace
Fixes [Bug #21145]
be2d845639
This commit is contained in:
parent
8324e3148a
commit
2db365dc83
2 changed files with 7 additions and 2 deletions
|
@ -9776,7 +9776,7 @@ escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expre
|
|||
|
||||
size_t whitespace;
|
||||
while (true) {
|
||||
if ((whitespace = pm_strspn_whitespace(parser->current.end, parser->end - parser->current.end)) > 0) {
|
||||
if ((whitespace = pm_strspn_inline_whitespace(parser->current.end, parser->end - parser->current.end)) > 0) {
|
||||
parser->current.end += whitespace;
|
||||
} else if (peek(parser) == '\\' && peek_offset(parser, 1) == 'n') {
|
||||
// This is super hacky, but it gets us nicer error
|
||||
|
@ -9824,7 +9824,7 @@ escape_read(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_t *regular_expre
|
|||
uint32_t value = escape_unicode(parser, unicode_start, hexadecimal_length);
|
||||
escape_write_unicode(parser, buffer, flags, unicode_start, parser->current.end, value);
|
||||
|
||||
parser->current.end += pm_strspn_whitespace(parser->current.end, parser->end - parser->current.end);
|
||||
parser->current.end += pm_strspn_inline_whitespace(parser->current.end, parser->end - parser->current.end);
|
||||
}
|
||||
|
||||
// ?\u{nnnn} character literal should contain only one codepoint
|
||||
|
|
5
test/prism/errors/escape_unicode_curly_whitespace.txt
Normal file
5
test/prism/errors/escape_unicode_curly_whitespace.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
"\u{
|
||||
^ invalid Unicode escape sequence
|
||||
^ unterminated Unicode escape
|
||||
61}"
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue