mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Simplify octal handling
This commit is contained in:
@@ -280,13 +280,14 @@ abstract class RegexString extends StringLiteral {
|
||||
or
|
||||
// octal value \0o, \0oo, or \0ooo. Max of 0377.
|
||||
this.getChar(start + 1) = "0" and
|
||||
end in [start + 3 .. start + 5] and
|
||||
forall(int i | i in [start + 1 .. end - 1] | this.isOctal(i)) and
|
||||
(end = start + 5 implies this.getChar(start + 2) <= "3") and
|
||||
not (
|
||||
end < start + 5 and
|
||||
this.isOctal(end) and
|
||||
(end = start + 4 implies this.getChar(start + 2) <= "3")
|
||||
this.isOctal(start + 2) and
|
||||
(
|
||||
if this.isOctal(start + 3)
|
||||
then
|
||||
if this.isOctal(start + 4) and this.getChar(start + 2) in ["0", "1", "2", "3"]
|
||||
then end = start + 5
|
||||
else end = start + 4
|
||||
else end = start + 3
|
||||
)
|
||||
or
|
||||
// 16-bit hex value \uhhhh
|
||||
|
||||
@@ -130,3 +130,10 @@ parseFailures
|
||||
| Test.java:18:18:18:18 | e | [RegExpConstant,RegExpNormalChar] |
|
||||
| Test.java:18:20:18:20 | f | [RegExpConstant,RegExpNormalChar] |
|
||||
| Test.java:18:22:18:22 | g | [RegExpConstant,RegExpNormalChar] |
|
||||
| Test.java:19:10:19:12 | \\01 | [RegExpConstant,RegExpEscape] |
|
||||
| Test.java:19:10:19:27 | \\018\\033\\0377\\0777 | [RegExpSequence] |
|
||||
| Test.java:19:13:19:13 | 8 | [RegExpConstant,RegExpNormalChar] |
|
||||
| Test.java:19:14:19:17 | \\033 | [RegExpConstant,RegExpEscape] |
|
||||
| Test.java:19:18:19:22 | \\0377 | [RegExpConstant,RegExpEscape] |
|
||||
| Test.java:19:23:19:26 | \\077 | [RegExpConstant,RegExpEscape] |
|
||||
| Test.java:19:27:19:27 | 7 | [RegExpConstant,RegExpNormalChar] |
|
||||
|
||||
@@ -15,7 +15,8 @@ class Test {
|
||||
"(?>hi)(?<name>hell*?o*+)123\\k<name>",
|
||||
"a+b*c?d{2}e{3,4}f{,5}g{6,}h+?i*?j??k{7}?l{8,9}?m{,10}?n{11,}?o++p*+q?+r{12}+s{13,14}+t{,15}+u{16,}+",
|
||||
"(?i)(?=a)(?!b)(?<=c)(?<!d)",
|
||||
"a|b|c(d|e)f|g"
|
||||
"a|b|c(d|e)f|g",
|
||||
"\\018\\033\\0377\\0777"
|
||||
};
|
||||
|
||||
void test() {
|
||||
|
||||
Reference in New Issue
Block a user