File tree 5 files changed +52
-6
lines changed
src/JavaScriptEngineSwitcher.Jint
test/JavaScriptEngineSwitcher.Tests/Jint
5 files changed +52
-6
lines changed Original file line number Diff line number Diff line change 18
18
<Import Project =" ../../build/nuget-for-dotnet-lib.props" />
19
19
20
20
<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 >
22
22
<PackageTags >$(PackageCommonTags);Jint</PackageTags >
23
23
<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 >
25
26
</PropertyGroup >
26
27
27
28
<ItemGroup >
28
29
<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 " />
30
31
31
32
<ProjectReference Include =" ../JavaScriptEngineSwitcher.Core/JavaScriptEngineSwitcher.Core.csproj" />
32
33
</ItemGroup >
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ public sealed class JintJsEngine : JsEngineBase
52
52
/// <summary>
53
53
/// Version of original JS engine
54
54
/// </summary>
55
- private const string EngineVersion = "3.0.0 Beta 2034 " ;
55
+ private const string EngineVersion = "3.0.0 Beta 2035 " ;
56
56
57
57
/// <summary>
58
58
/// Jint JS engine
@@ -124,6 +124,7 @@ public JintJsEngine(JintSettings settings)
124
124
. LimitMemory ( jintSettings . MemoryLimit )
125
125
. LimitRecursion ( jintSettings . MaxRecursionDepth )
126
126
. LocalTimeZone ( jintSettings . LocalTimeZone ?? TimeZoneInfo . Local )
127
+ . MaxArraySize ( jintSettings . MaxArraySize )
127
128
. MaxStatements ( jintSettings . MaxStatements )
128
129
. Strict ( jintSettings . StrictMode )
129
130
. TimeoutInterval ( jintSettings . TimeoutInterval )
Original file line number Diff line number Diff line change @@ -66,6 +66,15 @@ public TimeZoneInfo LocalTimeZone
66
66
set ;
67
67
}
68
68
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
+
69
78
/// <summary>
70
79
/// Gets or sets a maximum allowed depth of recursion:
71
80
/// -1 - recursion without limits;
@@ -145,6 +154,7 @@ public JintSettings()
145
154
DebuggerStepCallback = null ;
146
155
EnableDebugging = false ;
147
156
LocalTimeZone = TimeZoneInfo . Local ;
157
+ MaxArraySize = uint . MaxValue ;
148
158
MaxRecursionDepth = - 1 ;
149
159
MaxStatements = 0 ;
150
160
MemoryLimit = 0 ;
Original file line number Diff line number Diff line change 13
13
===========
14
14
JavaScriptEngineSwitcher.Jint contains adapter `JintJsEngine` (wrapper for the
15
15
Jint JavaScript Engine (http://github.com/sebastienros/jint) version
16
- 3.0.0 Beta 2034 ).
16
+ 3.0.0 Beta 2035 ).
17
17
18
18
=============
19
19
RELEASE NOTES
20
20
=============
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`).
22
24
23
25
=============
24
26
DOCUMENTATION
Original file line number Diff line number Diff line change @@ -218,6 +218,38 @@ public void MappingRuntimeErrorDuringOutOfMemoryIsCorrect()
218
218
Assert . Matches ( @"^Script has allocated \d+ but is limited to 2097152$" , exception . Description ) ;
219
219
}
220
220
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
+
221
253
[ Fact ]
222
254
public void MappingRuntimeErrorDuringRecursionDepthOverflowIsCorrect ( )
223
255
{
You can’t perform that action at this time.
0 commit comments