mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fixed error messages at non-ascii %string terminator
This commit is contained in:
parent
cc36b5d4ac
commit
445e5548c9
2 changed files with 8 additions and 0 deletions
6
parse.y
6
parse.y
|
@ -8547,11 +8547,17 @@ parse_percent(struct parser_params *p, const int space_seen, const enum lex_stat
|
|||
quotation:
|
||||
if (c == -1 || !ISALNUM(c)) {
|
||||
term = c;
|
||||
if (!ISASCII(c)) goto unknown;
|
||||
c = 'Q';
|
||||
}
|
||||
else {
|
||||
term = nextc(p);
|
||||
if (rb_enc_isalnum(term, p->enc) || !parser_isascii(p)) {
|
||||
unknown:
|
||||
pushback(p, term);
|
||||
c = parser_precise_mbclen(p, p->lex.pcur);
|
||||
if (c < 0) return 0;
|
||||
p->lex.pcur += c;
|
||||
yyerror0("unknown type of %string");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -599,6 +599,8 @@ class TestParse < Test::Unit::TestCase
|
|||
assert_syntax_error('%s', /unterminated quoted string/)
|
||||
assert_syntax_error('%ss', /unknown type/)
|
||||
assert_syntax_error('%z()', /unknown type/)
|
||||
assert_syntax_error("%\u3042", /unknown type/)
|
||||
assert_syntax_error("%q\u3042", /unknown type/)
|
||||
end
|
||||
|
||||
def test_symbol
|
||||
|
|
Loading…
Reference in a new issue