diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-12-27 09:01:08 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-12-27 09:01:08 +0900 |
| commit | f226bc20f6df09eb2b988562b4ac9fdc6958c8b0 (patch) | |
| tree | d315f3610d4a3088773691c981529d3d703ec3af | |
| parent | 4d8c9c131021316b854c4c8b877110d5584069d3 (diff) | |
[Bug #20986] [Prism] Allow escaped multibyte character
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12477
| -rw-r--r-- | prism/prism.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/prism/prism.c b/prism/prism.c index 04c9ca4ac1..eca276a357 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -9618,10 +9618,15 @@ escape_write_escape_encoded(pm_parser_t *parser, pm_buffer_t *buffer, pm_buffer_ if (width == 1) { escape_write_byte(parser, buffer, regular_expression_buffer, flags, escape_byte(*parser->current.end++, flags)); + } else if (width > 1) { + // Valid multibyte character. Just ignore escape. + pm_buffer_t *b = (flags & PM_ESCAPE_FLAG_REGEXP) ? regular_expression_buffer : buffer; + pm_buffer_append_bytes(b, parser->current.end, width); + parser->current.end += width; } else { // Assume the next character wasn't meant to be part of this escape // sequence since it is invalid. Add an error and move on. - parser->current.end += width; + parser->current.end++; pm_parser_err_current(parser, PM_ERR_ESCAPE_INVALID_CONTROL); } } |
