Skip to content

Refuse file: URLs in fetch and XMLHttpRequest from documents that are not file: - #56

Merged
FlorianRappl merged 2 commits into
AngleSharp:develfrom
michaelthyregod:fix/fetch-file-urls
Nov 4, 2026
Merged

FlorianRappl merged 2 commits into
AngleSharp:develfrom
michaelthyregod:fix/fetch-file-urls

Conversation

@michaelthyregod

Copy link
Copy Markdown
Contributor

Code for #53.

A page loaded over http(s), data: or about: could read local files with fetch or XMLHttpRequest, either directly or through a redirect to file:. On Windows, file://host/share/x also makes the process connect to that host's file share.

  • Rule: like browsers, only a file: document may request file: URLs from script now (FileUrlPolicy).
  • Behaviour: fetch rejects ("Failed to fetch"), and XHR fires error without sending a request.
  • Redirects: a response that ends up at file: is dropped in both.
  • Unaffected: file: documents, other schemes, and OpenAsync from C#.

Tests: a direct request, a redirect, a file: page that still works, and XHR.

🤖 Generated with Claude Code

…themselves

A page loaded over http(s), data: or about: could read local files with fetch or
XMLHttpRequest, directly or through a redirect to file:. Like browsers, only a file:
document may request file: URLs from script now. fetch rejects, XHR fires error
without sending a request.
@CLAassistant

CLAassistant commented Nov 4, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@FlorianRappl FlorianRappl added this to the v1.3.0 milestone Nov 4, 2026
@FlorianRappl
FlorianRappl merged commit 94eabdd into AngleSharp:devel Nov 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants