-
Notifications
You must be signed in to change notification settings - Fork 820
feat: Add support for file:// URIs in iOS and macOS WebView
#21573
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
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: MartinZikmund <[email protected]>
|
|
file:// URIs in iOS WebViewfile:// URIs in iOS and macOS WebView
|
@copilot add runtime test that covers this scenario |
Co-authored-by: MartinZikmund <[email protected]>
Added runtime test |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21573/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21573/wasm-skia-net9/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21573/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21573/docs/index.html |
|
|
Summary
This PR enables support for
file://URIs with relative paths in iOS and macOSWebViewimplementations by configuringWKWebViewto allow file access from file URLs. This fixes the issue where local HTML files could not load additional resources (CSS, JavaScript, images) using relative paths.Problem
By default,
WKWebViewblocks file URLs from accessing other file URLs for security reasons. This prevents legitimate use cases such as:Solution
Following the approach from .NET MAUI #19486, this PR enables the
allowFileAccessFromFileURLspreference onWKWebViewconfiguration during initialization.Changes Made
iOS/macOS Native WebView (
UnoWKWebView.iOSmacOS.cs)macOS Skia Native WebView (
UNOWebView.m)Runtime Test (
Given_WebView.cs)When_FileUri_With_Relative_Pathstest that verifies file:// URIs can load relative resourcesallowFileAccessFromFileURLsworks correctlyAll changes are applied during WebView initialization, ensuring consistent behavior across iOS and macOS platforms.
Use Cases
This enables scenarios like:
Testing
Security Considerations
This change follows the same security model as .NET MAUI and only affects
file://URLs. HTTP/HTTPS content security remains unchanged.References
Fixes #21572
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.