Skip to content

Commit ec650b8

Browse files
committed
Swift: Fix mistakes in ts in the tests and test comments.
1 parent 61079e0 commit ec650b8

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

swift/ql/test/query-tests/Security/CWE-116/BadTagFilter.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@
2121
| test.swift:202:51:202:104 | (<[a-z\\/!$]("[^"]*"\|'[^']*'\|[^'">])*>\|<!(--.*?--\\s*)+>) | Comments ending with --> are matched differently from comments ending with --!>. The first is matched with capture group 3 and comments ending with --!> are matched with capture group 1. |
2222
| test.swift:206:51:206:293 | <(?:(?:!--([\\w\\W]*?)-->)\|(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)\|(?:!DOCTYPE([\\w\\W]*?)>)\|(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)\|(?:\\/([A-Za-z][A-Za-z0-9\\-_\\:\\.]*)>)\|(?:([A-Za-z][A-Za-z0-9\\-_\\:\\.]*)((?:\\s+[^"'>]+(?:(?:"[^"]*")\|(?:'[^']*')\|[^>]*))*\|\\/\|\\s+)>)) | This regular expression only parses --> (capture group 1) and not --!> as an HTML comment end tag. |
2323
| test.swift:210:51:210:77 | <!--([\\w\\W]*?)-->\|<([^>]*?)> | Comments ending with --> are matched differently from comments ending with --!>. The first is matched with capture group 1 and comments ending with --!> are matched with capture group 2. |
24-
| test.swift:214:51:214:93 | <script([^>]*)>([\\\\S\\\\s]*?)<\\/script([^>]*)> | This regular expression does not match script end tags like </script >. |
2524
| test.swift:218:51:218:52 | --> | This regular expression only parses --> and not --!> as a HTML comment end tag. |

swift/ql/test/query-tests/Security/CWE-116/test.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func myRegexpVariantsTests(myUrl: URL) throws {
106106
let re6 = try Regex(#"<!--.*--!?>"#).ignoresCase(true)
107107
_ = try re6.firstMatch(in: tainted)
108108

109-
// BAD - doesn't match inside the script tag
109+
// BAD - doesn't match newlines inside the script tag
110110
let re7 = try Regex(#"<script.*?>(.|\s)*?<\/script[^>]*>"#).ignoresCase(true)
111111
_ = try re7.firstMatch(in: tainted)
112112

@@ -210,8 +210,8 @@ func myRegexpVariantsTests(myUrl: URL) throws {
210210
let ns2_4 = try NSRegularExpression(pattern: #"<!--([\w\W]*?)-->|<([^>]*?)>"#)
211211
_ = ns2_4.matches(in: tainted, range: NSMakeRange(0, tainted.utf16.count))
212212

213-
// GOOD - it's used with the ignorecase flag [FALSE POSITIVE]
214-
let ns2_5 = try NSRegularExpression(pattern: #"<script([^>]*)>([\\S\\s]*?)<\/script([^>]*)>"#, options: .caseInsensitive)
213+
// GOOD - it's used with the ignorecase flag
214+
let ns2_5 = try NSRegularExpression(pattern: #"<script([^>]*)>([\S\s]*?)<\/script([^>]*)>"#, options: .caseInsensitive)
215215
_ = ns2_5.matches(in: tainted, range: NSMakeRange(0, tainted.utf16.count))
216216

217217
// BAD - doesn't match --!>

0 commit comments

Comments
 (0)