diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-06-06 13:50:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-06 13:50:03 -0700 |
commit | ec3542229b29ec93062e9d90e877ea29d3c19472 (patch) | |
tree | 1f96f5d38b24e9605bccf074765a23c6a6e018a8 /common.mk | |
parent | c85d1cda86d75ee2c3f7b42f22c543409cb5a186 (diff) | |
download | ruby-ec3542229b29ec93062e9d90e877ea29d3c19472.tar.gz |
Ignore invalid escapes in regexp comments
Invalid escapes are handled at multiple levels. The first level
is in parse.y, so skip invalid unicode escape checks for regexps
in parse.y.
Make rb_reg_preprocess and unescape_nonascii accept the regexp
options. In unescape_nonascii, if the regexp is an extended
regexp, when "#" is encountered, ignore all characters until the
end of line or end of regexp.
Unfortunately, in extended regexps, you can use "#" as a non-comment
character inside a character class, so also parse "[" and "]"
specially for extended regexps, and only skip comments if "#" is
not inside a character class. Handle nested character classes as well.
This issue doesn't just affect extended regexps, it also affects
"(#?" comments inside all regexps. So for those comments, scan
until trailing ")" and ignore content inside.
I'm not sure if there are other corner cases not handled. A
better fix would be to redesign the regexp parser so that it
unescaped during parsing instead of before parsing, so you already
know the current parsing state.
Fixes [Bug #18294]
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Diffstat (limited to 'common.mk')
0 files changed, 0 insertions, 0 deletions