Skip to content

[iOS/Mac] Keep an HtmlWebViewSource.BaseUrl with a scheme as a URL - #40150

Merged
kubaflo merged 2 commits into
dotnet:candidate/11.0.1xx-sr2from
Kebechet:fix-19792-ios-htmlsource-baseurl
Nov 11, 2026
Merged

kubaflo merged 2 commits into
dotnet:candidate/11.0.1xx-sr2from
Kebechet:fix-19792-ios-htmlsource-baseurl

Conversation

@Kebechet

Copy link
Copy Markdown
Contributor

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

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). 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

kubaflo and others added 2 commits November 10, 2026 01:36
<!-- 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
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40150

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40150"

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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.

@azure-pipelines

This comment has been minimized.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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.

@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Nov 11, 2026
@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@Kebechet — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 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.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 11, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Expert Review — 0 findings

Reviewed commit 736e782.

@kubaflo
kubaflo changed the base branch from net11 to candidate/11.0.1xx-sr2 November 11, 2026 19:34
@kubaflo
kubaflo merged commit f7d5c05 into dotnet:candidate/11.0.1xx-sr2 Nov 11, 2026
10 of 29 checks passed
kubaflo added a commit that referenced this pull request Nov 11, 2026
…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>
kubaflo added a commit that referenced this pull request Nov 13, 2026
…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>
kubaflo added a commit that referenced this pull request Nov 16, 2026
…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>
kubaflo added a commit that referenced this pull request Nov 16, 2026
…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>
kubaflo added a commit that referenced this pull request Nov 17, 2026
…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>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…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>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…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>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…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>
kubaflo added a commit that referenced this pull request Nov 19, 2026
…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>
kubaflo added a commit that referenced this pull request Nov 22, 2026
…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>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…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>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…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>

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 736e782d Deployed Nov 11, 2026 by Kebechet via conclusion #2879
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants