Repository navigation
Load every module through the resource loader - #153
Merged
Merged
Conversation
FlorianRappl
reviewed
Nov 4, 2026
JsModuleLoader fetched only http and https modules through AngleSharp's
IResourceLoader. Every other URL went to Jint's DefaultModuleLoader, which
reads it from the local disk, so any page could import file: URLs (through
an import map, a direct specifier or import()) and read or run local files.
Bytes modules (with { type: 'bytes' }) always took Jint's file path.
- LoadModuleContents and LoadModuleContentsAsBytes both go through the
resource loader for every scheme, so the registered requesters decide
what a page can reach; a host that wants local modules registers a
requester for file:
- A missing response is reported as an error instead of a
NullReferenceException
- Module resolution is unchanged
- Tests: a page at https://example.com/ cannot read a temporary local file
as a JSON, JavaScript or bytes module, through any of the three ways in
Fixes AngleSharp#150
michaelthyregod
force-pushed
the
issue-150
branch
from
November 4, 2026 13:02
84f94f7 to
b344c15
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Types of Changes
Prerequisites
Please make sure you can check the following two boxes:
Contribution Type
What types of changes does your code introduce? Put an
xin all the boxes that apply:Description
Fixes #150, option (1): every module is loaded through AngleSharp's
IResourceLoader, whatever its scheme.JsModuleLoader.LoadModuleContentsno longer hands non-http(s) URLs to Jint'sDefaultModuleLoader, which read them from the local disk.LoadModuleContentsAsBytesis overridden the same way. This was a second path to the disk, forimport … with { type: 'bytes' }, which Jint's loader always served from the file system.NullReferenceException.Normal web use is unaffected:
http/httpsmodules already went through the resource loader, and all existing module tests pass. A host that loads modules from disk on purpose now registers a requester forfile:. That's the only behaviour change.Tests:
EcmaTests.ModuleIsNotReadFromTheLocalDiskhas 5 cases. A page athttps://example.com/tries to read a temporary local file through a direct specifier, an import map,import(), a.jsmodule and a bytes module. All 5 fail without the change and pass with it.Test runs (Windows 11, .NET SDK 10.0.403, the two classes that go online excluded):
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1).NumbersAreGivenAsNumbers("decimal")andMethodOverloadFittingTheArgumentsIsCalled("overloaded([1.5, 2])")fail under a culture with a decimal comma, such as en-DK, because the tests format the result with the current culture.CrossOriginTests.MessageReachesAFrameOfAnotherOriginWithWhoSentItis intermittent (here on net462 and net472). I've found the cause and will report it separately.All library targets build with 0 warnings.
Not in this PR, on purpose:
FetchModulestill blocks on.Task.Resultand doesn't check the response status. Happy to follow up on those separately if you want.🤖 Generated with Claude Code