mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 110f242ef9
: [Backport #17861]
Also `\U` after control/meta is invalid [Bug #17861] As well as `\u`, `\U` should be invalid there too. And highlight including `u`/`U` not only the backslash before it. --- parse.y | 12 ++++++++++-- test/ruby/test_parse.rb | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-)
This commit is contained in:
parent
5e21726cda
commit
af9de56c6f
3 changed files with 26 additions and 3 deletions
12
parse.y
12
parse.y
|
@ -6763,7 +6763,11 @@ read_escape(struct parser_params *p, int flags, rb_encoding **encp)
|
||||||
goto eof;
|
goto eof;
|
||||||
}
|
}
|
||||||
if ((c = nextc(p)) == '\\') {
|
if ((c = nextc(p)) == '\\') {
|
||||||
if (peek(p, 'u')) goto eof;
|
switch (peekc(p)) {
|
||||||
|
case 'u': case 'U':
|
||||||
|
nextc(p);
|
||||||
|
goto eof;
|
||||||
|
}
|
||||||
return read_escape(p, flags|ESCAPE_META, encp) | 0x80;
|
return read_escape(p, flags|ESCAPE_META, encp) | 0x80;
|
||||||
}
|
}
|
||||||
else if (c == -1 || !ISASCII(c)) goto eof;
|
else if (c == -1 || !ISASCII(c)) goto eof;
|
||||||
|
@ -6788,7 +6792,11 @@ read_escape(struct parser_params *p, int flags, rb_encoding **encp)
|
||||||
case 'c':
|
case 'c':
|
||||||
if (flags & ESCAPE_CONTROL) goto eof;
|
if (flags & ESCAPE_CONTROL) goto eof;
|
||||||
if ((c = nextc(p))== '\\') {
|
if ((c = nextc(p))== '\\') {
|
||||||
if (peek(p, 'u')) goto eof;
|
switch (peekc(p)) {
|
||||||
|
case 'u': case 'U':
|
||||||
|
nextc(p);
|
||||||
|
goto eof;
|
||||||
|
}
|
||||||
c = read_escape(p, flags|ESCAPE_CONTROL, encp);
|
c = read_escape(p, flags|ESCAPE_CONTROL, encp);
|
||||||
}
|
}
|
||||||
else if (c == '?')
|
else if (c == '?')
|
||||||
|
|
|
@ -562,6 +562,21 @@ class TestParse < Test::Unit::TestCase
|
||||||
assert_syntax_error("\"\\M-\x01\"", 'Invalid escape character syntax')
|
assert_syntax_error("\"\\M-\x01\"", 'Invalid escape character syntax')
|
||||||
assert_syntax_error("\"\\M-\\C-\x01\"", 'Invalid escape character syntax')
|
assert_syntax_error("\"\\M-\\C-\x01\"", 'Invalid escape character syntax')
|
||||||
assert_syntax_error("\"\\C-\\M-\x01\"", 'Invalid escape character syntax')
|
assert_syntax_error("\"\\C-\\M-\x01\"", 'Invalid escape character syntax')
|
||||||
|
|
||||||
|
e = assert_syntax_error('"\c\u0000"', 'Invalid escape character syntax')
|
||||||
|
assert_equal(' ^~~~'"\n", e.message.lines.last)
|
||||||
|
e = assert_syntax_error('"\c\U0000"', 'Invalid escape character syntax')
|
||||||
|
assert_equal(' ^~~~'"\n", e.message.lines.last)
|
||||||
|
|
||||||
|
e = assert_syntax_error('"\C-\u0000"', 'Invalid escape character syntax')
|
||||||
|
assert_equal(' ^~~~~'"\n", e.message.lines.last)
|
||||||
|
e = assert_syntax_error('"\C-\U0000"', 'Invalid escape character syntax')
|
||||||
|
assert_equal(' ^~~~~'"\n", e.message.lines.last)
|
||||||
|
|
||||||
|
e = assert_syntax_error('"\M-\u0000"', 'Invalid escape character syntax')
|
||||||
|
assert_equal(' ^~~~~'"\n", e.message.lines.last)
|
||||||
|
e = assert_syntax_error('"\M-\U0000"', 'Invalid escape character syntax')
|
||||||
|
assert_equal(' ^~~~~'"\n", e.message.lines.last)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_question
|
def test_question
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||||
#define RUBY_VERSION_TEENY 2
|
#define RUBY_VERSION_TEENY 2
|
||||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||||
#define RUBY_PATCHLEVEL 80
|
#define RUBY_PATCHLEVEL 81
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2021
|
#define RUBY_RELEASE_YEAR 2021
|
||||||
#define RUBY_RELEASE_MONTH 5
|
#define RUBY_RELEASE_MONTH 5
|
||||||
|
|
Loading…
Reference in a new issue