mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
* parse.y (parser_tokadd_string): escape simple regexp meta
character termninators. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8a4de7abf8
commit
bc6dde9420
3 changed files with 53 additions and 2 deletions
14
parse.y
14
parse.y
|
@ -6440,6 +6440,18 @@ parser_tokadd_mbchar(struct parser_params *parser, int c)
|
|||
|
||||
#define tokadd_mbchar(c) parser_tokadd_mbchar(parser, (c))
|
||||
|
||||
static inline int
|
||||
simple_re_meta(int c)
|
||||
{
|
||||
switch (c) {
|
||||
case '$': case '*': case '+': case '.':
|
||||
case '?': case '^': case '|':
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
parser_tokadd_string(struct parser_params *parser,
|
||||
int func, int term, int paren, long *nest,
|
||||
|
@ -6520,7 +6532,7 @@ parser_tokadd_string(struct parser_params *parser,
|
|||
goto non_ascii;
|
||||
}
|
||||
if (func & STR_FUNC_REGEXP) {
|
||||
if (c == term) {
|
||||
if (c == term && !simple_re_meta(c)) {
|
||||
tokadd(c);
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue