Skip to content

Commit 576f0d5

Browse files
authored
Merge pull request #19 from browserstack/fix/DEVA11Y-479-block-file-scheme
fix(security): restrict download URL override to HTTPS only [DEVA11Y-479]
2 parents 543f5bd + 461b589 commit 576f0d5

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

Plugins/BrowserStackAccessibilityLint/BrowserStackAccessibilityLint.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,13 @@ private func parseOverride(urlString: String?) throws -> URL? {
100100
guard let urlString = urlString, !urlString.isEmpty else {
101101
return nil
102102
}
103-
if let url = URL(string: urlString), let scheme = url.scheme, ["http", "https", "file"].contains(scheme.lowercased()) {
104-
return url
103+
guard let url = URL(string: urlString), let scheme = url.scheme else {
104+
throw PluginError("Invalid download URL: \(urlString). Only HTTPS URLs are supported.")
105+
}
106+
guard scheme.lowercased() == "https" else {
107+
throw PluginError("Unsupported URL scheme '\(scheme)' in download URL. Only HTTPS is allowed.")
105108
}
106-
return URL(fileURLWithPath: urlString)
109+
return url
107110
}
108111

109112
private func sanitizeArguments(_ arguments: [String]) -> [String] {

0 commit comments

Comments
 (0)