mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-12-16 04:23:31 +00:00
Update AssemblyLoader.cs and examples (Catswords.Phantomizer)
Update AssemblyLoader.cs and examples (Catswords.Phantomizer)
This commit is contained in:
parent
c96100b716
commit
7d5c60d0a3
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user