Skip to content

Commit

Permalink
Upgrade to Jint 3.0.2 (#15667)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma authored Apr 5, 2024
1 parent 5f65445 commit 961fe39
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 93 deletions.
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

0 comments on commit 961fe39

Please sign in to comment.