@@ -124,16 +124,40 @@ abstract class RegexString extends Expr {
124124 )
125125 }
126126
127+ /** Named unicode characters, eg \N{degree sign} */
128+ private predicate escapedName ( int start , int end ) {
129+ this .escapingChar ( start ) and
130+ this .getChar ( start + 1 ) = "N" and
131+ this .getChar ( start + 2 ) = "{" and
132+ this .getChar ( end - 1 ) = "}" and
133+ end > start and
134+ not exists ( int i | start + 2 < i and i < end - 1 |
135+ this .getChar ( i ) = "}"
136+ )
137+ }
138+
127139 private predicate escapedCharacter ( int start , int end ) {
128140 this .escapingChar ( start ) and
129141 not exists ( this .getText ( ) .substring ( start + 1 , end + 1 ) .toInt ( ) ) and
130142 (
143+ // hex value \xhh
131144 this .getChar ( start + 1 ) = "x" and end = start + 4
132145 or
146+ // octal value \ooo
133147 end in [ start + 2 .. start + 4 ] and
134148 exists ( this .getText ( ) .substring ( start + 1 , end ) .toInt ( ) )
135149 or
136- this .getChar ( start + 1 ) != "x" and end = start + 2
150+ // 16-bit hex value \uhhhh
151+ this .getChar ( start + 1 ) = "u" and end = start + 6
152+ or
153+ // 32-bit hex value \Uhhhhhhhh
154+ this .getChar ( start + 1 ) = "U" and end = start + 10
155+ or
156+ escapedName ( start , end )
157+ or
158+ // escape not handled above, update when adding a new case
159+ not this .getChar ( start + 1 ) in [ "x" , "u" , "U" , "N" ] and
160+ end = start + 2
137161 )
138162 }
139163
0 commit comments