Update AssemblyLoader.cs and examples (Catswords.Phantomizer)

Update AssemblyLoader.cs and examples (Catswords.Phantomizer)
This commit is contained in:
Namhyeon, Go 2025-12-14 19:15:51 +09:00
parent c96100b716
commit 7d5c60d0a3
2 changed files with 8 additions and 3 deletions

View File

@ -46,7 +46,7 @@ namespace Catswords.Phantomizer
private static readonly object SyncRoot = new object();
private static bool _registered;
private static List<string> _allowSchemes = new List<string> {
private static readonly HashSet<string> _allowSchemes = new HashSet<string>(StringComparer.OrdinalIgnoreCase) {
Uri.UriSchemeHttps
};
@ -291,6 +291,8 @@ namespace Catswords.Phantomizer
if (!Uri.CheckSchemeName(scheme))
throw new ArgumentException("Invalid URI scheme name.", nameof(scheme));
scheme = scheme.ToLowerInvariant();
if (scheme.Equals(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase))
Trace.TraceWarning("Warning: Adding 'http' to allowed URI schemes reduces security.");
@ -679,7 +681,10 @@ namespace Catswords.Phantomizer
if (uri == null)
return false;
return _allowSchemes.Contains(uri.Scheme);
lock (SyncRoot)
{
return _allowSchemes.Contains(uri.Scheme);
}
}
}
}

View File

@ -71,7 +71,7 @@ private static void InitializeAssemblyLoader()
//loaderType.GetProperty("IntegrityUrl")?.SetValue(null, GetAppConfig("IntegrityUrl")); // (Optional) Set the integrity URL
loaderType.GetProperty("LoaderNamespace")?.SetValue(null, typeof(Program).Namespace);
loaderType.GetProperty("AppName")?.SetValue(null, "WelsonJS"); // Application name
//loaderType.GetMethod("AddAllowedUriScheme")?.Invoke(null, Uri.UriSchemeHttp); // (Optional) Allow insecure HTTP (not recommended)
//loaderType.GetMethod("AddAllowedUriScheme")?.Invoke(null, new object[] { Uri.UriSchemeHttp }); // (Optional) Allow insecure HTTP (not recommended)
loaderType.GetMethod("Register")?.Invoke(null, null);
var loadNativeModulesMethod = loaderType.GetMethod(