mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Revert "Swift: Fix two of the qhelps by slightly modifying the sample code instead."
This reverts commit 2d19d6f61e.
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
|
||||
</p>
|
||||
|
||||
<sample src="IncompleteHostnameRegexBad.swift"/>
|
||||
<sample src="IncompleteHostnameRegexBad.swift" language=""/>
|
||||
|
||||
<p>
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
|
||||
</p>
|
||||
|
||||
<sample src="IncompleteHostnameRegexGood.swift"/>
|
||||
<sample src="IncompleteHostnameRegexGood.swift" language=""/>
|
||||
|
||||
</example>
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
func handleUrl(_ urlString: String) throws {
|
||||
func handleUrl(_ urlString: String) {
|
||||
// get the 'url=' parameter from the URL
|
||||
let components = URLComponents(string: urlString)
|
||||
let redirectParam = components?.queryItems?.first(where: { $0.name == "url" })
|
||||
|
||||
// check we trust the host
|
||||
let regex = try Regex("^(www|beta).example.com/") // BAD
|
||||
let regex = #/^(www|beta).example.com//# // BAD
|
||||
if let match = redirectParam?.value?.firstMatch(of: regex) {
|
||||
// ... trust the URL ...
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
func handleUrl(_ urlString: String) throws {
|
||||
func handleUrl(_ urlString: String) {
|
||||
// get the 'url=' parameter from the URL
|
||||
let components = URLComponents(string: urlString)
|
||||
let redirectParam = components?.queryItems?.first(where: { $0.name == "url" })
|
||||
|
||||
// check we trust the host
|
||||
let regex = try Regex("^(www|beta)\\.example\\.com/") // GOOD
|
||||
let regex = #/^(www|beta)\.example\.com//# // GOOD
|
||||
if let match = redirectParam?.value?.firstMatch(of: regex) {
|
||||
// ... trust the URL ...
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ likely to handle corner cases correctly than a custom implementation.
|
||||
The following example attempts to filters out all <code><script></code> tags.
|
||||
</p>
|
||||
|
||||
<sample src="BadTagFilterBad.swift" />
|
||||
<sample src="BadTagFilterBad.swift" language="" />
|
||||
|
||||
<p>
|
||||
The above sanitizer does not filter out all <code><script></code> tags.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
let script_tag_regex = try Regex("<script[^>]*>.*</script>")
|
||||
let script_tag_regex = /<script[^>]*>.*<\/script>/
|
||||
|
||||
var old_html = ""
|
||||
while (html != old_html) {
|
||||
|
||||
Reference in New Issue
Block a user