Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Jint 3.0.2 #15667

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/OrchardCore.Build/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PackageManagement Include="GraphQL.DataLoader" Version="7.8.0" />
<PackageManagement Include="GraphQL.MicrosoftDI" Version="7.8.0" />
<PackageManagement Include="GraphQL.SystemTextJson" Version="7.8.0" />
<PackageManagement Include="Jint" Version="3.0.1" />
<PackageManagement Include="Jint" Version="3.0.2" />
<PackageManagement Include="JsonPath.Net" Version="1.0.0" />
<PackageManagement Include="HtmlSanitizer" Version="8.1.860-beta" />
<PackageManagement Include="Irony.Core" Version="1.0.7" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,7 @@ public JavaScriptEngine(IMemoryCache memoryCache)

public IScriptingScope CreateScope(IEnumerable<GlobalMethod> methods, IServiceProvider serviceProvider, IFileProvider fileProvider, string basePath)
{
var engine = new Engine(options =>
{
// Make JsonArray behave like JS array.
options.SetWrapObjectHandler(static (e, target, type) =>
{
if (target is JsonArray)
{
var wrapped = new ObjectWrapper(e, target)
{
Prototype = e.Intrinsics.Array.PrototypeObject
};
return wrapped;
}

return new ObjectWrapper(e, target);
});

options.AddObjectConverter<JsonValueConverter>();

// We cannot access this[string] with anything else than JsonObject, otherwise itw will throw.
options.SetTypeResolver(new TypeResolver
{
MemberFilter = static info =>
{
if (info.ReflectedType != typeof(JsonObject) && info.Name == "Item" && info is PropertyInfo p)
{
var parameters = p.GetIndexParameters();
return parameters.Length != 1 || parameters[0].ParameterType != typeof(string);
}

return true;
}
});
});
var engine = new Engine();

foreach (var method in methods)
{
Expand All @@ -78,7 +45,7 @@ static void ThrowInvalidScopeTypeException()
ThrowInvalidScopeTypeException();
}

var parsedAst = _memoryCache.GetOrCreate(script, static entry => Engine.PrepareScript((string)entry.Key));
var parsedAst = _memoryCache.GetOrCreate(script, static entry => Engine.PrepareScript((string) entry.Key));

var result = jsScope.Engine.Evaluate(parsedAst).ToObject();

Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/docs/resources/libraries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The below table lists the different .NET libraries used in Orchard Core:
| [HtmlSanitizer](https://github.com/mganss/HtmlSanitizer) | Cleans HTML to avoid XSS attacks. | 8.1.860-beta | [MIT](https://github.com/mganss/HtmlSanitizer/blob/master/LICENSE.md) |
| [Image Sharp](https://github.com/SixLabors/ImageSharp.Web) | Middleware for ASP.NET-Core for image manipulation. | 3.1.1 |[Apache-2.0](https://github.com/SixLabors/ImageSharp.Web/blob/master/LICENSE) |
| [Irony.Core](https://github.com/daxnet/irony) | A modified version of the Irony project with .NET Core support | 1.0.7 | [MIT](https://github.com/daxnet/irony/blob/master/LICENSE) |
| [Jint](https://github.com/sebastienros/jint) | Javascript Interpreter for .NET. | 3.0.1 | [MIT](https://github.com/sebastienros/jint/blob/dev/LICENSE) |
| [Jint](https://github.com/sebastienros/jint) | Javascript Interpreter for .NET. | 3.0.2 | [MIT](https://github.com/sebastienros/jint/blob/dev/LICENSE) |
| [libphonenumber-csharp](https://github.com/twcclegg/libphonenumber-csharp) | .NET library for parsing, formatting, and validating international phone numbers | 8.13.33 | [Apache-2.0](https://github.com/twcclegg/libphonenumber-csharp/blob/main/LICENSE) |
| [Lorem.NET for netstandard](https://github.com/trichards57/Lorem.Universal.NET) | A .NET library for all things random! | 4.0.80 | [MIT](https://github.com/trichards57/Lorem.Universal.NET/blob/master/license.md) |
| [Lucene.Net](https://github.com/apache/lucenenet) | .NET full-text search engine. | 4.8.0-beta00016 | [Apache-2.0](https://github.com/apache/lucenenet/blob/master/LICENSE.txt) |
Expand Down
Loading