Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit 9060fce

Browse files
committed
Merge branch 'hotfix/7.141.1'
# By Michal Smaga (1) and Sam Symons (1) # Via GitHub * hotfix/7.141.1: Release 7.141.1-0 (#3479) Handle 'data' scheme downloads through WebKit's `decisionHandler(.download)` (#3478) # Conflicts: # Configuration/Version.xcconfig # DuckDuckGo/Settings.bundle/Root.plist
2 parents a0f4e64 + 17e373e commit 9060fce

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

DuckDuckGo/TabViewController.swift

+8-1
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,7 @@ extension TabViewController: WKNavigationDelegate {
13251325

13261326
let mimeType = MIMEType(from: navigationResponse.response.mimeType, fileExtension: navigationResponse.response.url?.pathExtension)
13271327
let urlSchemeType = navigationResponse.response.url.map { SchemeHandler.schemeType(for: $0) } ?? .unknown
1328+
let urlNavigationalScheme = navigationResponse.response.url?.scheme.map { URL.NavigationalScheme(rawValue: $0) }
13281329

13291330
let httpResponse = navigationResponse.response as? HTTPURLResponse
13301331
let isSuccessfulResponse = httpResponse?.isSuccessfulResponse ?? false
@@ -1355,7 +1356,13 @@ extension TabViewController: WKNavigationDelegate {
13551356
withAdditionalParameters: [PixelParameters.canAutoPreviewMIMEType: "1"])
13561357
} else if shouldTriggerDownloadAction(for: navigationResponse),
13571358
let downloadMetadata = AppDependencyProvider.shared.downloadManager.downloadMetaData(for: navigationResponse.response) {
1358-
// 3. We know the response should trigger the file download prompt
1359+
// 3a. We know it is a download, but allow WebKit handle the "data" scheme natively
1360+
if urlNavigationalScheme == .data {
1361+
decisionHandler(.download)
1362+
return
1363+
}
1364+
1365+
// 3b. We know the response should trigger the file download prompt
13591366
self.presentSaveToDownloadsAlert(with: downloadMetadata) {
13601367
self.startDownload(with: navigationResponse, decisionHandler: decisionHandler)
13611368
} cancelHandler: {

0 commit comments

Comments
 (0)