mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
RUBY-12161: special case to parse valid octal chars
#RUBY-12161 fixed
This commit is contained in:
@@ -57,7 +57,23 @@ public class RegExpCharImpl extends RegExpElementImpl implements RegExpChar {
|
||||
@Nullable
|
||||
public Character getValue() {
|
||||
final String s = getUnescapedText();
|
||||
if (s.equals("\\") && getType() == Type.CHAR) return '\\';
|
||||
if (s.equals("\\") && getType() == Type.CHAR) {
|
||||
return '\\';
|
||||
}
|
||||
// special case for valid octal escaped sequences (see RUBY-12161)
|
||||
if (s.startsWith("\\") && s.length() > 1) {
|
||||
final ASTNode child = getNode().getFirstChildNode();
|
||||
assert child != null;
|
||||
final IElementType t = child.getElementType();
|
||||
if (t == RegExpTT.OCT_CHAR) {
|
||||
try {
|
||||
return (char) Integer.parseInt(s.substring(1), 8);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
return unescapeChar(s);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user