File tree Expand file tree Collapse file tree 1 file changed +8
-22
lines changed
swift/ql/lib/codeql/swift/regex/internal Expand file tree Collapse file tree 1 file changed +8
-22
lines changed Original file line number Diff line number Diff line change @@ -303,41 +303,27 @@ abstract class RegExp extends Expr {
303
303
*/
304
304
string getModeFromPrefix ( ) {
305
305
exists ( string c | this .flagGroup ( _, _, c ) |
306
- // TODO: are these correct in Swift?
307
- c = "i" and result = "IGNORECASE"
306
+ c = "i" and result = "IGNORECASE" // case insensitive
308
307
or
309
- c = "m " and result = "MULTILINE"
308
+ c = "x " and result = "VERBOSE" // ignores whitespace and `#` comments within patterns
310
309
or
311
- c = "s" and result = "DOTALL"
310
+ c = "s" and result = "DOTALL" // dot matches all characters, including line terminators
312
311
or
313
- c = "u " and result = "UNICODE"
312
+ c = "m " and result = "MULTILINE" // `^` and `$` also match beginning and end of lines
314
313
or
315
- c = "x" and result = "VERBOSE"
316
- or
317
- c = "U" and result = "UNICODECLASS"
314
+ c = "w" and result = "UNICODE" // Unicode UAX 29 word boundary mode
318
315
)
319
316
}
320
317
321
318
/**
322
319
* Gets a mode (if any) of this regular expression. Can be any of:
323
- * DEBUG
324
320
* IGNORECASE
325
- * MULTILINE
321
+ * VERBOSE
326
322
* DOTALL
323
+ * MULTILINE
327
324
* UNICODE
328
- * VERBOSE
329
- * UNICODECLASS
330
325
*/
331
- string getAMode ( ) {
332
- /*
333
- * TODO
334
- * result != "None" and
335
- * usedAsRegex(this, result, _)
336
- * or
337
- */
338
-
339
- result = this .getModeFromPrefix ( )
340
- }
326
+ string getAMode ( ) { result = this .getModeFromPrefix ( ) }
341
327
342
328
/**
343
329
* Holds if the `i`th character could not be parsed.
You can’t perform that action at this time.
0 commit comments