Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 457cf41

Browse files
Support more escaped characters
1 parent 4b845d5 commit 457cf41

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

java/ql/lib/semmle/code/java/regex/RegexTreeView.qll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,12 @@ class RegExpEscape extends RegExpNormalChar {
480480
or
481481
this.getUnescaped() = "t" and result = "\t"
482482
or
483-
// TODO: Find a way to include a formfeed character
484-
// also the alert/bell character for \a and escape character for \e.
485-
// this.getUnescaped() = "f" and result = " "
486-
// or
483+
this.getUnescaped() = "f" and result = 12.toUnicode() // form feed
484+
or
485+
this.getUnescaped() = "a" and result = 7.toUnicode() // alert/bell
486+
or
487+
this.getUnescaped() = "e" and result = 27.toUnicode() // escape (0x1B)
488+
or
487489
this.isUnicode() and
488490
result = this.getUnicode()
489491
}
@@ -664,6 +666,7 @@ class RegExpCharacterRange extends RegExpTerm, TRegExpCharacterRange {
664666
/**
665667
* A normal character in a regular expression, that is, a character
666668
* without special meaning. This includes escaped characters.
669+
* It also includes escape sequences that represent character classes.
667670
*
668671
* Examples:
669672
* ```
@@ -727,11 +730,8 @@ class RegExpConstant extends RegExpTerm {
727730
string value;
728731

729732
RegExpConstant() {
730-
(this = TRegExpNormalChar(re, start, end) or this = TRegExpQuote(re, start, end)) and
731-
not this instanceof RegExpCharacterClassEscape and
732-
// exclude chars in quantifiers
733-
// TODO: push this into regex library
734-
(value = this.(RegExpNormalChar).getValue() or value = this.(RegExpQuote).getValue())
733+
(value = this.(RegExpNormalChar).getValue() or value = this.(RegExpQuote).getValue()) and
734+
not this instanceof RegExpCharacterClassEscape
735735
}
736736

737737
/**

0 commit comments

Comments
 (0)