mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 59161: [Backport #13672]
parse.y: check multibyte char * parse.y (parser_precise_mbclen): check invalid multibyte char at skipping strings following `?x` literal string, not to stuck in a infinite loop. [ruby-core:81746] [Bug #13672] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@59241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
25a2e376bb
commit
5974191113
4 changed files with 23 additions and 7 deletions
|
@ -1,3 +1,9 @@
|
|||
Fri Jun 30 22:05:39 2017 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (parser_precise_mbclen): check invalid multibyte char at
|
||||
skipping strings following ?x literal string, not to stuck in a
|
||||
infinite loop. [Bug #13672]
|
||||
|
||||
Fri Jun 30 22:00:56 2017 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/pathname/lib/pathname.rb (Pathname#plus): UNC root pathname needs
|
||||
|
|
20
parse.y
20
parse.y
|
@ -5333,7 +5333,6 @@ ripper_dispatch_delayed_token(struct parser_params *parser, int t)
|
|||
|
||||
#define parser_encoding_name() (current_enc->name)
|
||||
#define parser_mbclen() mbclen((lex_p-1),lex_pend,current_enc)
|
||||
#define parser_precise_mbclen() rb_enc_precise_mbclen((lex_p-1),lex_pend,current_enc)
|
||||
#define is_identchar(p,e,enc) (rb_enc_isalnum((unsigned char)(*(p)),(enc)) || (*(p)) == '_' || !ISASCII(*(p)))
|
||||
#define parser_is_identchar() (!parser->eofp && is_identchar((lex_p-1),lex_pend,current_enc))
|
||||
|
||||
|
@ -5406,6 +5405,18 @@ token_info_pop(struct parser_params *parser, const char *token, size_t len)
|
|||
xfree(ptinfo);
|
||||
}
|
||||
|
||||
static int
|
||||
parser_precise_mbclen(struct parser_params *parser, const char *p)
|
||||
{
|
||||
int len = rb_enc_precise_mbclen(p, lex_pend, current_enc);
|
||||
if (!MBCLEN_CHARFOUND_P(len)) {
|
||||
compile_error(PARSER_ARG "invalid multibyte char (%s)", parser_encoding_name());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
parser_yyerror(struct parser_params *parser, const char *msg)
|
||||
{
|
||||
|
@ -6186,11 +6197,8 @@ dispose_string(VALUE str)
|
|||
static int
|
||||
parser_tokadd_mbchar(struct parser_params *parser, int c)
|
||||
{
|
||||
int len = parser_precise_mbclen();
|
||||
if (!MBCLEN_CHARFOUND_P(len)) {
|
||||
compile_error(PARSER_ARG "invalid multibyte char (%s)", parser_encoding_name());
|
||||
return -1;
|
||||
}
|
||||
int len = parser_precise_mbclen(parser, lex_p-1);
|
||||
if (len < 0) return -1;
|
||||
tokadd(c);
|
||||
lex_p += --len;
|
||||
if (len > 0) tokcopy(len);
|
||||
|
|
|
@ -512,6 +512,8 @@ class TestParse < Test::Unit::TestCase
|
|||
assert_raise(SyntaxError) { eval("?\v") }
|
||||
assert_raise(SyntaxError) { eval("?\r") }
|
||||
assert_raise(SyntaxError) { eval("?\f") }
|
||||
assert_raise(SyntaxError) { eval("?\f") }
|
||||
assert_raise(SyntaxError) { eval(" ?a\x8a".force_encoding("utf-8")) }
|
||||
assert_equal("\u{1234}", eval("?\u{1234}"))
|
||||
assert_equal("\u{1234}", eval('?\u{1234}'))
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#define RUBY_VERSION "2.3.5"
|
||||
#define RUBY_RELEASE_DATE "2017-06-30"
|
||||
#define RUBY_PATCHLEVEL 337
|
||||
#define RUBY_PATCHLEVEL 338
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2017
|
||||
#define RUBY_RELEASE_MONTH 6
|
||||
|
|
Loading…
Add table
Reference in a new issue