Skip to content

Commit

Permalink
Merge branch 'hotfix/7.141.1'
Browse files Browse the repository at this point in the history
# 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
  • Loading branch information
samsymons committed Oct 24, 2024
2 parents a0f4e64 + 17e373e commit 9060fce
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,7 @@ extension TabViewController: WKNavigationDelegate {

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

let httpResponse = navigationResponse.response as? HTTPURLResponse
let isSuccessfulResponse = httpResponse?.isSuccessfulResponse ?? false
Expand Down Expand Up @@ -1355,7 +1356,13 @@ extension TabViewController: WKNavigationDelegate {
withAdditionalParameters: [PixelParameters.canAutoPreviewMIMEType: "1"])
} else if shouldTriggerDownloadAction(for: navigationResponse),
let downloadMetadata = AppDependencyProvider.shared.downloadManager.downloadMetaData(for: navigationResponse.response) {
// 3. We know the response should trigger the file download prompt
// 3a. We know it is a download, but allow WebKit handle the "data" scheme natively
if urlNavigationalScheme == .data {
decisionHandler(.download)
return
}

// 3b. We know the response should trigger the file download prompt
self.presentSaveToDownloadsAlert(with: downloadMetadata) {
self.startDownload(with: navigationResponse, decisionHandler: decisionHandler)
} cancelHandler: {
Expand Down

0 comments on commit 9060fce

Please sign in to comment.