Repository navigation
Conversation
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [ ] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change <!-- Enter description of the fix in this section --> <!-- maui-release-normalization:production:11.0.1xx-sr1 --> Restore **`net11`** to the next-cycle CI version after pinning the exact SR1 staging source. Approved candidate merge: `01c74ef93c991830e310a77ec808b51b29bcac1f`. Prepared normalization: `429a19c17072142e3570618dcb498da6a1adbf25`. This pinned child commit changes only version metadata: patch 20, CI/non-stable settings, and that same plain version in both bug-template dropdowns. SDK band and release contents are unchanged. **A maintainer must review this PR, run required CI and use Create a merge commit. Do not squash or rebase.** The reconciler does not update the protected integration ref, approve, retarget or merge this PR. Next-lane activation and forward-flow preparation wait for the normalization ancestry to be verified. The automation/release staging ref starts at this candidate source and advances through its separately reviewed servicing PR. A newer maintainer candidate merge supersedes the old generation, never a concurrent unrelated edit. After servicing is merged with Create a merge commit, the real release branch is manually cut at its exact merge. This normalization PR does not authorize signing. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> N/A - staged release configuration. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. -->
MauiWKWebView.LoadHtml passed every BaseUrl to new NSUrl(baseUrl, true), which is initFileURLWithPath:isDirectory:. A URL such as https://example.com/ was treated as a relative file path and became a file URL under the current directory, so the loaded document never got the origin the app asked for. A BaseUrl that has a scheme is now used as is. A file system path, such as NSBundle.MainBundle.BundlePath, still becomes a directory file URL. dotnet#19792
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40150Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40150" |
|
Hey there @@Kebechet! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This comment has been minimized.
This comment has been minimized.
|
Hey there @Kebechet! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Test Gate
🧪 Gate analysis — click to expand⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect. No interpretable test-group summary was produced. No additional test execution is inferred. Setup did not capture a verified PR head; no commit is claimed as tested. No immutable without-fix baseline was prepared. |
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit 736e782.
f7d5c05
into
dotnet:candidate/11.0.1xx-sr2
…40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes #19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes #19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes #19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes #19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes #19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes #19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes #19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes #19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes #19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes #19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes #19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…otnet#40150) ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). ### Description of Change On iOS and Mac Catalyst, `HtmlWebViewSource.BaseUrl` is not used as a URL. `MauiWKWebView.LoadHtml` passes every value to `new NSUrl(baseUrl, true)`, which is `initFileURLWithPath:isDirectory:`. A URL such as `https://example.com/` is treated as a relative file path and becomes a `file:` URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break: - relative URLs that should resolve against a remote base - cookies and storage scoped to that origin - services that identify the embedding app by its `Referer`. For example, YouTube's embedded player requires one ([Required Minimum Functionality](https://developers.google.com/youtube/terms/required-minimum-functionality)). Google's documented way to provide it on iOS is `loadHTMLString:baseURL:` with an https base URL, which is what `HtmlWebViewSource.BaseUrl` maps to. With this bug the player shows "Error 153". Android already passes `BaseUrl` to `LoadDataWithBaseURL` as a URL, so this makes iOS and Mac Catalyst behave like Android. **Change:** `LoadHtml` resolves the base URL in a new `ResolveBaseUrl`: | `BaseUrl` | Before | After | | --- | --- | --- | | `https://example.com/` | `file:///…/https:/example.com/` (a file URL under the current directory) | `https://example.com/` | | a file system path, e.g. `NSBundle.MainBundle.BundlePath` | directory file URL | unchanged | | `null` / empty | app bundle path | unchanged | A value counts as a URL when `NSUrl.FromString` parses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected. No open PR addresses this issue. ### Tests Device tests in `WebViewHandlerTests.iOS.cs` (it also compiles for Mac Catalyst). Each loads HTML with a `BaseUrl` and reads `document.baseURI` from the page: - `HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrl` for `https://example.com/` and `https://example.com/content/` - `HtmlSourceBaseUrlFilePathStaysFileUrl`, which pins the existing file-path behaviour - `HtmlWebViewSourceStub` gains a `BaseUrl` property for these tests Run locally with xharness, `Category=WebView`, on this branch's base `net11` (e7f7353): | Run | Result | | --- | --- | | iOS simulator 26.5, without the fix | both scheme cases fail: `Expected "https://example.com/"`, `Actual "file:///Users/…/Library/Develop…"`. The file-path case passes. | | iOS simulator 26.5, with the fix | 79 passed, 0 failed, 2 skipped | | Mac Catalyst, with the fix | 74 passed, 0 failed, 7 skipped | ### Issues Fixed Fixes dotnet#19792 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Target Branch
mainnet11, for reviewDescription of Change
On iOS and Mac Catalyst,
HtmlWebViewSource.BaseUrlis not used as a URL.MauiWKWebView.LoadHtmlpasses every value tonew NSUrl(baseUrl, true), which isinitFileURLWithPath:isDirectory:. A URL such ashttps://example.com/is treated as a relative file path and becomes afile:URL under the current directory. The loaded document therefore never gets the origin the app asked for, so these break:Referer. For example, YouTube's embedded player requires one (Required Minimum Functionality). Google's documented way to provide it on iOS isloadHTMLString:baseURL:with an https base URL, which is whatHtmlWebViewSource.BaseUrlmaps to. With this bug the player shows "Error 153".Android already passes
BaseUrltoLoadDataWithBaseURLas a URL, so this makes iOS and Mac Catalyst behave like Android.Change:
LoadHtmlresolves the base URL in a newResolveBaseUrl:BaseUrlhttps://example.com/file:///…/https:/example.com/(a file URL under the current directory)https://example.com/NSBundle.MainBundle.BundlePathnull/ emptyA value counts as a URL when
NSUrl.FromStringparses it with a scheme. Anything else keeps the existing file-path behaviour, so apps that pass a bundle path for local content are not affected.No open PR addresses this issue.
Tests
Device tests in
WebViewHandlerTests.iOS.cs(it also compiles for Mac Catalyst). Each loads HTML with aBaseUrland readsdocument.baseURIfrom the page:HtmlSourceBaseUrlWithSchemeIsDocumentBaseUrlforhttps://example.com/andhttps://example.com/content/HtmlSourceBaseUrlFilePathStaysFileUrl, which pins the existing file-path behaviourHtmlWebViewSourceStubgains aBaseUrlproperty for these testsRun locally with xharness,
Category=WebView, on this branch's basenet11(e7f7353):Expected "https://example.com/",Actual "file:///Users/…/Library/Develop…". The file-path case passes.Issues Fixed
Fixes #19792