Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Link Tracking Protection to preserve headers #2268

Merged
merged 5 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9225,7 +9225,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 98.0.1;
version = 99.0.0;
};
};
C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "ea133abe237b6cb57a4237e0373318a40c10afc2",
"version" : "98.0.1"
"revision" : "2c1c2bb0aad5a23524e298fa9bea9b890ae43e23",
"version" : "99.0.0"
}
},
{
Expand Down Expand Up @@ -122,8 +122,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
"revision" : "8f4d2753f0e4778c76d5f05ad16c74f707390531",
"version" : "1.2.3"
}
},
{
Expand Down
24 changes: 9 additions & 15 deletions DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -426,25 +426,25 @@ class TabViewController: UIViewController {

if consumeCookies {
consumeCookiesThenLoadRequest(request)
} else if let url = request?.url {
} else if let urlRequest = request {
var loadingStopped = false
linkProtection.getCleanURL(from: url, onStartExtracting: { [weak self] in
linkProtection.getCleanURLRequest(from: urlRequest, onStartExtracting: { [weak self] in
if loadingInitiatedByParentTab {
// stop parent-initiated URL loading only if canonical URL extraction process has started
loadingStopped = true
self?.webView.stopLoading()
}
self?.showProgressIndicator()
}, onFinishExtracting: {}, completion: { [weak self] cleanURL in
}, onFinishExtracting: {}, completion: { [weak self] cleanURLRequest in
// restart the cleaned-up URL loading here if:
// link protection provided an updated URL
// OR if loading was stopped for a popup loaded by its parent
// OR for any other navigation which is not a popup loaded by its parent
// the check is here to let an (about:blank) popup which has its loading
// initiated by its parent to keep its active request, otherwise we would
// break a js-initiated popup request such as printing from a popup
guard url != cleanURL || loadingStopped || !loadingInitiatedByParentTab else { return }
self?.load(urlRequest: .userInitiated(cleanURL))
guard self?.url != cleanURLRequest.url || loadingStopped || !loadingInitiatedByParentTab else { return }
self?.load(urlRequest: cleanURLRequest)
})
}

Expand Down Expand Up @@ -488,7 +488,7 @@ class TabViewController: UIViewController {
webView.evaluateJavaScript(js)
}
}

public func load(url: URL) {
webView.stopLoading()
dismissJSAlertIfNeeded()
Expand Down Expand Up @@ -551,6 +551,7 @@ class TabViewController: UIViewController {
}

webView.stopLoading()
dismissJSAlertIfNeeded()
webView.load(urlRequest)
}

Expand Down Expand Up @@ -1351,16 +1352,9 @@ extension TabViewController: WKNavigationDelegate {
navigationAction: navigationAction,
onStartExtracting: { showProgressIndicator() },
onFinishExtracting: { },
onLinkRewrite: { [weak self] newURL, navigationAction in
onLinkRewrite: { [weak self] newRequest, _ in
guard let self = self else { return }
if self.isNewTargetBlankRequest(navigationAction: navigationAction) {
self.delegate?.tab(self,
didRequestNewTabForUrl: newURL,
openedByPage: true,
inheritingAttribution: self.adClickAttributionLogic.state)
} else {
self.load(url: newURL)
}
self.load(urlRequest: newRequest)
SlayterDev marked this conversation as resolved.
Show resolved Hide resolved
},
policyDecisionHandler: decisionHandler)

Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DuckUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let package = Package(
targets: ["DuckUI"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.1"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "99.0.0"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SyncUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let package = Package(
],
dependencies: [
.package(path: "../DuckUI"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.1"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "99.0.0"),
.package(url: "https://github.com/duckduckgo/DesignResourcesKit", exact: "2.0.0")
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/Waitlist/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
targets: ["Waitlist", "WaitlistMocks"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "98.0.1"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "99.0.0"),
.package(url: "https://github.com/duckduckgo/DesignResourcesKit", exact: "2.0.0")
],
targets: [
Expand Down
Loading