Skip to content

[MOB-8537] updates action runner logic to check allowed protocols #769

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
33 changes: 19 additions & 14 deletions swift-sdk/Internal/ActionRunner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,28 @@ struct ActionRunner {
customActionHandler: CustomActionHandler? = nil,
urlOpener: UrlOpenerProtocol? = nil,
allowedProtocols: [String] = []) -> Bool {
let handled = callExternalHandlers(action: action,
from: context.source,
urlHandler: urlHandler,
customActionHandler: customActionHandler)

if handled {
guard case let .openUrl(url) = detectActionType(fromAction: action),
shouldOpenUrl(url: url, from: context.source, withAllowedProtocols: allowedProtocols) else {
return false
}

if case let handled = callExternalHandlers(action: action,
from: context.source,
urlHandler: urlHandler,
customActionHandler: customActionHandler), handled {
Comment on lines +38 to +41
Copy link
Preview

Copilot AI May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using case let for a Boolean result is unconventional. Replace if case let handled = ... with let handled = ... outside the if, then if handled { ... } for clarity.

Copilot uses AI. Check for mistakes.

return true
}

if case let .openUrl(url) = detectActionType(fromAction: action),
let urlOpener = urlOpener {
urlOpener.open(url: url)
return true
} else {
if case let .openUrl(url) = detectActionType(fromAction: action),
shouldOpenUrl(url: url, from: context.source, withAllowedProtocols: allowedProtocols),
let urlOpener = urlOpener {
urlOpener.open(url: url)
return true
} else {
return false
}
}

return false

Comment on lines +33 to +52
Copy link
Preview

Copilot AI May 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guard only allows openUrl actions through and returns false for all other action types, preventing external/custom handlers from running on non-URL actions. Consider separating the protocol check into the URL branch so other action types still invoke callExternalHandlers.

Copilot uses AI. Check for mistakes.


}

// MARK: - Private
Expand Down
Loading