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: external application requests via redirect URLs shows wrong origin. #1900

Merged
merged 7 commits into from
Dec 20, 2023
Merged
Changes from 4 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
5 changes: 3 additions & 2 deletions DuckDuckGo/Tab/Navigation/ExternalAppSchemeHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ extension ExternalAppSchemeHandler: NavigationResponder {
}

let permissionType = PermissionType.externalScheme(scheme: scheme)
// use domain from the url for user-entered app schemes, otherwise use current website domain
let domain = navigationAction.isUserEnteredUrl ? navigationAction.url.host ?? "" : navigationAction.sourceFrame.securityOrigin.host
// Check for cross-origin redirects first, then use domain from the url for user-entered app schemes, then use current website domain
let redirectDomain = navigationAction.redirectHistory?.reversed().first(where: { $0.url.host != navigationAction.url.host })?.url.host
let domain = redirectDomain ?? (navigationAction.isUserEnteredUrl ? navigationAction.url.host ?? "" : navigationAction.sourceFrame.securityOrigin.host)
permissionModel.permissions([permissionType], requestedForDomain: domain, url: externalUrl) { [workspace] isGranted in
if isGranted {
workspace.open(externalUrl)
Expand Down