Skip to content

Commit 0088ece

Browse files
committed
Revert "Swift: Fix two of the qhelps by slightly modifying the sample code instead."
This reverts commit 2d19d6f.
1 parent 2d19d6f commit 0088ece

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

swift/ql/src/queries/Security/CWE-020/IncompleteHostnameRegex.qhelp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
</p>
4848

49-
<sample src="IncompleteHostnameRegexBad.swift"/>
49+
<sample src="IncompleteHostnameRegexBad.swift" language=""/>
5050

5151
<p>
5252

@@ -63,7 +63,7 @@
6363

6464
</p>
6565

66-
<sample src="IncompleteHostnameRegexGood.swift"/>
66+
<sample src="IncompleteHostnameRegexGood.swift" language=""/>
6767

6868
</example>
6969

swift/ql/src/queries/Security/CWE-020/IncompleteHostnameRegexBad.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

2-
func handleUrl(_ urlString: String) throws {
2+
func handleUrl(_ urlString: String) {
33
// get the 'url=' parameter from the URL
44
let components = URLComponents(string: urlString)
55
let redirectParam = components?.queryItems?.first(where: { $0.name == "url" })
66

77
// check we trust the host
8-
let regex = try Regex("^(www|beta).example.com/") // BAD
8+
let regex = #/^(www|beta).example.com//# // BAD
99
if let match = redirectParam?.value?.firstMatch(of: regex) {
1010
// ... trust the URL ...
1111
}

swift/ql/src/queries/Security/CWE-020/IncompleteHostnameRegexGood.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

2-
func handleUrl(_ urlString: String) throws {
2+
func handleUrl(_ urlString: String) {
33
// get the 'url=' parameter from the URL
44
let components = URLComponents(string: urlString)
55
let redirectParam = components?.queryItems?.first(where: { $0.name == "url" })
66

77
// check we trust the host
8-
let regex = try Regex("^(www|beta)\\.example\\.com/") // GOOD
8+
let regex = #/^(www|beta)\.example\.com//# // GOOD
99
if let match = redirectParam?.value?.firstMatch(of: regex) {
1010
// ... trust the URL ...
1111
}

swift/ql/src/queries/Security/CWE-116/BadTagFilter.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ likely to handle corner cases correctly than a custom implementation.
2828
The following example attempts to filters out all <code>&lt;script&gt;</code> tags.
2929
</p>
3030

31-
<sample src="BadTagFilterBad.swift" />
31+
<sample src="BadTagFilterBad.swift" language="" />
3232

3333
<p>
3434
The above sanitizer does not filter out all <code>&lt;script&gt;</code> tags.

swift/ql/src/queries/Security/CWE-116/BadTagFilterBad.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
let script_tag_regex = try Regex("<script[^>]*>.*</script>")
1+
let script_tag_regex = /<script[^>]*>.*<\/script>/
22

33
var old_html = ""
44
while (html != old_html) {

0 commit comments

Comments
 (0)