Skip to content

[bug] iOS scene_continueUserActivity panics on malformed universal link URL #1251

Description

@velocitysystems

Describe the bug

scene_continueUserActivity in src/platform_impl/ios/scene.rs calls .unwrap() on a URL parse result, which will panic and crash the app if a universal link contains a malformed URL:

let url = url.to_string().parse::<url::Url>().unwrap();

The sibling scene_openURLContexts handler in the same file already handles parse failures gracefully using filter_map + log::error!:

url.parse()
    .map_err(|e| {
        log::error!("failed to parse URL {url} from scene:openURLContexts: {e}");
        e
    })
    .ok()

The two handlers should be consistent — a malformed URL should be logged and skipped, not cause a panic.

Steps To Reproduce

  1. Create a tao app with multi-scene support enabled (UIApplicationSupportsMultipleScenes: true in Info.plist)
  2. Register a universal link domain for the app
  3. Trigger a scene:continueUserActivity: callback with a webpageURL containing a malformed URL (e.g. via an NSUserActivity with an invalid URL string)
  4. The app panics at the .unwrap() in scene_continueUserActivity

Expected behavior

The malformed URL should be logged as an error and skipped, matching the behavior of scene_openURLContexts.

Screenshots

N/A

Platform and Versions:

  • OS: iPadOS 26
  • Rustc: 1.87
  • tao: 0.35.3

Additional context

The fix is straightforward — replace the .unwrap() with the same filter_map + log::error! pattern used in scene_openURLContexts:

fn scene_continueUserActivity(&self, _scene: &UIScene, user_activity: &NSUserActivity) {
    unsafe {
        // universal app links
        if let Some(url) = user_activity
            .webpageURL()
            .and_then(|url| url.absoluteString())
        {
            let url = url.to_string();
            match url.parse::<url::Url>() {
                Ok(url) => {
                    app_state::handle_nonuser_event(EventWrapper::StaticEvent(Event::Opened {
                        urls: vec![url],
                    }));
                }
                Err(e) => {
                    log::error!("failed to parse URL {url} from scene:continueUserActivity: {e}");
                }
            }
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions