mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #1038 from kouki-o-iij/pr-regexp-escape
bugfix escape charactor for Regexp class
This commit is contained in:
+4
-11
@@ -3459,17 +3459,9 @@ read_escape(parser_state *p)
|
||||
return c;
|
||||
|
||||
case 'b': /* backspace */
|
||||
if (is_strterm_type(p, STR_FUNC_REGEXP)) {
|
||||
tokadd(p, '\\');
|
||||
return 'b';
|
||||
}
|
||||
return '\010';
|
||||
|
||||
case 's': /* space */
|
||||
if (is_strterm_type(p, STR_FUNC_REGEXP)) {
|
||||
tokadd(p, '\\');
|
||||
return 's';
|
||||
}
|
||||
return ' ';
|
||||
|
||||
case 'M':
|
||||
@@ -3507,9 +3499,6 @@ read_escape(parser_state *p)
|
||||
return '\0';
|
||||
|
||||
default:
|
||||
if (is_strterm_type(p, STR_FUNC_REGEXP)) {
|
||||
tokadd(p, '\\');
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
@@ -3583,6 +3572,10 @@ parse_string(parser_state *p)
|
||||
}
|
||||
else {
|
||||
pushback(p, c);
|
||||
|
||||
if(type & STR_FUNC_REGEXP)
|
||||
tokadd(p, '\\');
|
||||
|
||||
tokadd(p, read_escape(p));
|
||||
if (hinf)
|
||||
hinf->line_head = FALSE;
|
||||
|
||||
Reference in New Issue
Block a user