Skip to content

Commit 6d4eecf

Browse files
committed
Ruby: Fix regex parsing of /[|]/
1 parent a7442b7 commit 6d4eecf

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

ruby/ql/lib/codeql/ruby/security/performance/ParseRegExp.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ abstract class RegExp extends AST::StringlikeLiteral {
861861
* Whether the text in the range start,end is an alternation
862862
*/
863863
predicate alternation(int start, int end) {
864+
not this.inCharSet(start) and
864865
this.topLevel(start, end) and
865866
exists(int less | this.subalternation(start, less, _) and less < end)
866867
}

ruby/ql/test/library-tests/regexp/parse.expected

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,8 @@ regexp.rb:
181181
# 26| [RegExpConstant, RegExpNormalChar] -
182182

183183
# 27| [RegExpCharacterClass] [|]
184-
#-----| 0 -> [RegExpAlt] |
185184
#-----| 0 -> [RegExpConstant, RegExpNormalChar] |
186185

187-
# 27| [RegExpAlt] |
188-
189186
# 27| [RegExpConstant, RegExpNormalChar] |
190187

191188
# 30| [RegExpCharacterClass] [[a-f]

0 commit comments

Comments
 (0)