@@ -96,8 +96,6 @@ static inline bool EndsWith(const std::string& value, const std::string& suffix)
9696 return std::equal (suffix.rbegin (), suffix.rend (), value.rbegin ());
9797}
9898
99- // Dev-only HTTP ESM loader helpers
100-
10199static inline bool StartsWith (const std::string& s, const char * prefix) {
102100 size_t n = strlen (prefix);
103101 return s.size () >= n && s.compare (0 , n, prefix) == 0 ;
@@ -725,7 +723,8 @@ static bool IsDocumentsPath(const std::string& path) {
725723
726724 // ── Early absolute-HTTP fast path ─────────────────────────────
727725 // If the specifier itself is an absolute HTTP(S) URL, resolve it immediately via
728- // the HTTP dev loader and return before any filesystem candidate logic runs.
726+ // the HTTP loader and return before any filesystem candidate logic runs.
727+ // Security: HttpFetchText gates remote module access centrally.
729728 if (StartsWith (spec, " http://" ) || StartsWith (spec, " https://" )) {
730729 std::string key = CanonicalizeHttpUrlKey (spec);
731730 // Added instrumentation for unified phase logging
@@ -825,6 +824,7 @@ static bool IsDocumentsPath(const std::string& path) {
825824 // ("./" or "../") or root-absolute ("/") specifiers should resolve against the
826825 // referrer's URL, not the local filesystem. Mirror browser behavior by using NSURL
827826 // to construct the absolute URL, then return an HTTP-loaded module immediately.
827+ // Security: HttpFetchText gates remote module access centrally.
828828 bool referrerIsHttp = (!referrerPath.empty () && (StartsWith (referrerPath, " http://" ) || StartsWith (referrerPath, " https://" )));
829829 bool specIsRootAbs = !spec.empty () && spec[0 ] == ' /' ;
830830 if (referrerIsHttp && (specIsRelative || specIsRootAbs)) {
@@ -845,6 +845,7 @@ static bool IsDocumentsPath(const std::string& path) {
845845 }
846846 }
847847 if (!resolvedHttp.empty () && (StartsWith (resolvedHttp, " http://" ) || StartsWith (resolvedHttp, " https://" ))) {
848+ // Security: HttpFetchText gates remote module access centrally.
848849 if (IsScriptLoadingLogEnabled ()) {
849850 Log (@" [resolver][http-rel] base=%s spec=%s -> %s " , referrerPath.c_str (), spec.c_str (), resolvedHttp.c_str ());
850851 }
@@ -1009,6 +1010,7 @@ static bool IsDocumentsPath(const std::string& path) {
10091010 std::string absPath;
10101011
10111012 // If the specifier is an HTTP(S) URL, fetch via HTTP loader and return
1013+ // Security: HttpFetchText gates remote module access centrally.
10121014 if (StartsWith (spec, " http://" ) || StartsWith (spec, " https://" )) {
10131015 std::string key = CanonicalizeHttpUrlKey (spec);
10141016 if (IsScriptLoadingLogEnabled ()) {
@@ -1095,6 +1097,7 @@ static bool IsDocumentsPath(const std::string& path) {
10951097
10961098 // If a candidate accidentally embeds a collapsed HTTP URL like '/app/http:/host/...',
10971099 // reconstruct the HTTP URL and resolve via the HTTP loader instead of touching the filesystem.
1100+ // Security: HttpFetchText gates remote module access centrally.
10981101 auto rerouteHttpIfEmbedded = [&](const std::string& p) -> bool {
10991102 size_t pos1 = p.find (" /http:/" );
11001103 size_t pos2 = p.find (" /https:/" );
@@ -1108,6 +1111,7 @@ static bool IsDocumentsPath(const std::string& path) {
11081111 tail.insert (6 , " /" );
11091112 }
11101113 if (!(StartsWith (tail, " http://" ) || StartsWith (tail, " https://" ))) return false ;
1114+
11111115 if (IsScriptLoadingLogEnabled ()) { Log (@" [resolver][http-embedded] %s -> %s " , p.c_str (), tail.c_str ()); }
11121116 std::string key = CanonicalizeHttpUrlKey (tail);
11131117 auto itExisting = g_moduleRegistry.find (key);
@@ -1912,6 +1916,7 @@ static bool IsDocumentsPath(const std::string& path) {
19121916 }
19131917
19141918 // If spec is an HTTP(S) URL, try HTTP fetch+compile directly
1919+ // Security: HttpFetchText gates remote module access centrally.
19151920 if (!normalizedSpec.empty () && (StartsWith (normalizedSpec, " http://" ) || StartsWith (normalizedSpec, " https://" ))) {
19161921 if (IsScriptLoadingLogEnabled ()) {
19171922 Log (@" [dyn-import][http-loader] trying URL %s " , normalizedSpec.c_str ());
0 commit comments