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

Fixed: App Crash on Ad Redirect to Unsupported URL Scheme #987

Merged
merged 1 commit into from
May 30, 2024

Conversation

weibel
Copy link
Contributor

@weibel weibel commented May 27, 2024

Description

During click handling, an attempt to open SFSafariViewController could result in a crash with the error:

The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported.

This PR addresses the issue by adding a check for the URL scheme in the PBMSafariVCOpener class to ensure it only attempts to open URLs with "http" or "https" schemes. If the URL has an unsupported scheme, the SDK will now log an error message and prevent SFSafariViewController from opening the unsupported URL, thereby preventing the app from crashing.

Background

This issue occurs when an ad redirects to "about" or when a user quickly clicks on an ad as soon as it appears, causing the app to crash due to an uncaught NSInvalidArgumentException. The fix ensures the app handles unsupported URL schemes gracefully.

Changes

Added a check for the URL scheme in the PBMSafariVCOpener class.
If the URL scheme is not "http" or "https", log an error message and do not attempt to open the URL in SFSafariViewController.

Fixes #966

@weibel weibel changed the title Fix crash in SFSafariViewController App Crash on Ad Redirect to Unsupported URL Scheme May 27, 2024
@weibel weibel changed the title App Crash on Ad Redirect to Unsupported URL Scheme Fixed: App Crash on Ad Redirect to Unsupported URL Scheme May 27, 2024
@jsligh jsligh self-requested a review May 30, 2024 17:27
@jsligh jsligh assigned jsligh and unassigned jsligh May 30, 2024
Copy link
Collaborator

@jsligh jsligh left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@jsligh jsligh merged commit 042857d into prebid:master May 30, 2024
@weibel weibel deleted the fix_openClickthroughWithURL_crash branch May 30, 2024 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash app with ads redirect to "about:blank"
2 participants