Skip to content

Commit 3f8b27c

Browse files
committed
Ruby: Add RegExpNonWordBoundary to RegExpTreeView
1 parent e3c3c00 commit 3f8b27c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

ruby/ql/lib/codeql/ruby/regexp/RegExpTreeView.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,15 @@ class RegExpWordBoundary extends RegExpSpecialChar {
581581
RegExpWordBoundary() { this.getChar() = "\\b" }
582582
}
583583

584+
/**
585+
* A non-word boundary, that is, a regular expression term of the form `\B`.
586+
*/
587+
class RegExpNonWordBoundary extends RegExpSpecialChar {
588+
RegExpNonWordBoundary() { this.getChar() = "\\B" }
589+
590+
override string getAPrimaryQlClass() { result = "RegExpNonWordBoundary" }
591+
}
592+
584593
/**
585594
* A character class escape in a regular expression.
586595
* That is, an escaped character that denotes multiple characters.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,11 @@ regexp.rb:
266266
# 43| [RegExpSequence] \b!a\B
267267
#-----| 0 -> [RegExpSpecialChar] \b
268268
#-----| 1 -> [RegExpConstant, RegExpNormalChar] !a
269-
#-----| 2 -> [RegExpSpecialChar] \B
269+
#-----| 2 -> [RegExpNonWordBoundary] \B
270270

271271
# 43| [RegExpConstant, RegExpNormalChar] !a
272272

273-
# 43| [RegExpSpecialChar] \B
273+
# 43| [RegExpNonWordBoundary] \B
274274

275275
# 46| [RegExpGroup] (foo)
276276
#-----| 0 -> [RegExpConstant, RegExpNormalChar] foo

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ term
108108
| regexp.rb:43:2:43:3 | \\b | RegExpSpecialChar |
109109
| regexp.rb:43:2:43:7 | \\b!a\\B | RegExpSequence |
110110
| regexp.rb:43:4:43:5 | !a | RegExpConstant,RegExpNormalChar |
111-
| regexp.rb:43:6:43:7 | \\B | RegExpSpecialChar |
111+
| regexp.rb:43:6:43:7 | \\B | RegExpNonWordBoundary |
112112
| regexp.rb:46:2:46:6 | (foo) | RegExpGroup |
113113
| regexp.rb:46:2:46:7 | (foo)* | RegExpStar |
114114
| regexp.rb:46:2:46:10 | (foo)*bar | RegExpSequence |

0 commit comments

Comments
 (0)