Skip to content

Commit 16640ca

Browse files
committed
In JavaScriptEngineSwitcher.Jint:
1. Jint was updated to version 3.0.0 Beta 2035; 2. In configuration settings of the Jint JS engine was added one new property - `MaxArraySize` (default `uint.MaxValue`).
1 parent 4c8f52f commit 16640ca

File tree

5 files changed

+52
-6
lines changed

5 files changed

+52
-6
lines changed

src/JavaScriptEngineSwitcher.Jint/JavaScriptEngineSwitcher.Jint.csproj

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818
<Import Project="../../build/nuget-for-dotnet-lib.props" />
1919

2020
<PropertyGroup>
21-
<Description>JavaScriptEngineSwitcher.Jint contains adapter `JintJsEngine` (wrapper for the Jint JavaScript Engine (http://github.com/sebastienros/jint) version 3.0.0 Beta 2034).</Description>
21+
<Description>JavaScriptEngineSwitcher.Jint contains adapter `JintJsEngine` (wrapper for the Jint JavaScript Engine (http://github.com/sebastienros/jint) version 3.0.0 Beta 2035).</Description>
2222
<PackageTags>$(PackageCommonTags);Jint</PackageTags>
2323
<PackageIconFullPath>../../Icons/JavaScriptEngineSwitcher_Jint_Logo128x128.png</PackageIconFullPath>
24-
<PackageReleaseNotes>Jint was updated to version 3.0.0 Beta 2034.</PackageReleaseNotes>
24+
<PackageReleaseNotes>1. Jint was updated to version 3.0.0 Beta 2035;
25+
2. In configuration settings of the Jint JS engine was added one new property - `MaxArraySize` (default `uint.MaxValue`).</PackageReleaseNotes>
2526
</PropertyGroup>
2627

2728
<ItemGroup>
2829
<PackageReference Include="AdvancedStringBuilder" Version="0.1.0" />
29-
<PackageReference Include="Jint" Version="3.0.0-beta-2034" />
30+
<PackageReference Include="Jint" Version="3.0.0-beta-2035" />
3031

3132
<ProjectReference Include="../JavaScriptEngineSwitcher.Core/JavaScriptEngineSwitcher.Core.csproj" />
3233
</ItemGroup>

src/JavaScriptEngineSwitcher.Jint/JintJsEngine.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public sealed class JintJsEngine : JsEngineBase
5252
/// <summary>
5353
/// Version of original JS engine
5454
/// </summary>
55-
private const string EngineVersion = "3.0.0 Beta 2034";
55+
private const string EngineVersion = "3.0.0 Beta 2035";
5656

5757
/// <summary>
5858
/// Jint JS engine
@@ -124,6 +124,7 @@ public JintJsEngine(JintSettings settings)
124124
.LimitMemory(jintSettings.MemoryLimit)
125125
.LimitRecursion(jintSettings.MaxRecursionDepth)
126126
.LocalTimeZone(jintSettings.LocalTimeZone ?? TimeZoneInfo.Local)
127+
.MaxArraySize(jintSettings.MaxArraySize)
127128
.MaxStatements(jintSettings.MaxStatements)
128129
.Strict(jintSettings.StrictMode)
129130
.TimeoutInterval(jintSettings.TimeoutInterval)

src/JavaScriptEngineSwitcher.Jint/JintSettings.cs

+10
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ public TimeZoneInfo LocalTimeZone
6666
set;
6767
}
6868

69+
/// <summary>
70+
/// Gets or sets a maximum size for JavaScript array
71+
/// </summary>
72+
public uint MaxArraySize
73+
{
74+
get;
75+
set;
76+
}
77+
6978
/// <summary>
7079
/// Gets or sets a maximum allowed depth of recursion:
7180
/// -1 - recursion without limits;
@@ -145,6 +154,7 @@ public JintSettings()
145154
DebuggerStepCallback = null;
146155
EnableDebugging = false;
147156
LocalTimeZone = TimeZoneInfo.Local;
157+
MaxArraySize = uint.MaxValue;
148158
MaxRecursionDepth = -1;
149159
MaxStatements = 0;
150160
MemoryLimit = 0;

src/JavaScriptEngineSwitcher.Jint/readme.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
===========
1414
JavaScriptEngineSwitcher.Jint contains adapter `JintJsEngine` (wrapper for the
1515
Jint JavaScript Engine (http://github.com/sebastienros/jint) version
16-
3.0.0 Beta 2034).
16+
3.0.0 Beta 2035).
1717

1818
=============
1919
RELEASE NOTES
2020
=============
21-
Jint was updated to version 3.0.0 Beta 2034.
21+
1. Jint was updated to version 3.0.0 Beta 2035;
22+
2. In configuration settings of the Jint JS engine was added one new property -
23+
`MaxArraySize` (default `uint.MaxValue`).
2224

2325
=============
2426
DOCUMENTATION

test/JavaScriptEngineSwitcher.Tests/Jint/CommonTests.cs

+32
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,38 @@ public void MappingRuntimeErrorDuringOutOfMemoryIsCorrect()
218218
Assert.Matches(@"^Script has allocated \d+ but is limited to 2097152$", exception.Description);
219219
}
220220

221+
[Fact]
222+
public void MappingRuntimeErrorDuringArraySizeExceededIsCorrect()
223+
{
224+
// Arrange
225+
const string input = @"var arr = new Array(1000000000);";
226+
227+
JsRuntimeException exception = null;
228+
229+
// Act
230+
using (IJsEngine jsEngine = new JintJsEngine(
231+
new JintSettings
232+
{
233+
MaxArraySize = 1_000_000
234+
}
235+
))
236+
{
237+
try
238+
{
239+
jsEngine.Execute(input);
240+
}
241+
catch (JsRuntimeException e)
242+
{
243+
exception = e;
244+
}
245+
}
246+
247+
// Assert
248+
Assert.NotNull(exception);
249+
Assert.Equal("Runtime error", exception.Category);
250+
Assert.Equal("The array size 1000000000 is larger than maximum allowed (1000000)", exception.Description);
251+
}
252+
221253
[Fact]
222254
public void MappingRuntimeErrorDuringRecursionDepthOverflowIsCorrect()
223255
{

0 commit comments

Comments
 (0)