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

Fix handling external schemes in address bar #493

Merged
merged 9 commits into from
Apr 1, 2022
17 changes: 9 additions & 8 deletions DuckDuckGo/Browser Tab/Model/Tab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -849,15 +849,16 @@ extension Tab: WKNavigationDelegate {
return .download(navigationAction, using: webView)

} else if url.isExternalSchemeLink {
// ignore <iframe src="custom://url"> but allow via address bar
guard navigationAction.sourceFrame.isMainFrame,
// ignore 2nd+ external scheme navigation not initiated by user
!self.externalSchemeOpenedPerPageLoad || navigationAction.isUserInitiated
else { return .cancel }

self.externalSchemeOpenedPerPageLoad = true
// always allow user entered URLs
if !userEnteredUrl {
// allow external links via address bar, but ignore <iframe src="custom://url">
guard navigationAction.sourceFrame.isMainFrame,
!self.externalSchemeOpenedPerPageLoad || navigationAction.isUserInitiated
else { return .cancel }

self.externalSchemeOpenedPerPageLoad = true
}
self.delegate?.tab(self, requestedOpenExternalURL: url, forUserEnteredURL: userEnteredUrl)

return .cancel
}

Expand Down