|
@@ -11,13 +11,12 @@ namespace Jint
|
|
public class Options
|
|
public class Options
|
|
{
|
|
{
|
|
private bool _discardGlobal;
|
|
private bool _discardGlobal;
|
|
- private bool _discardRecursion;
|
|
|
|
private bool _strict;
|
|
private bool _strict;
|
|
private bool _allowDebuggerStatement;
|
|
private bool _allowDebuggerStatement;
|
|
private bool _allowClr;
|
|
private bool _allowClr;
|
|
private readonly List<IObjectConverter> _objectConverters = new List<IObjectConverter>();
|
|
private readonly List<IObjectConverter> _objectConverters = new List<IObjectConverter>();
|
|
private int _maxStatements;
|
|
private int _maxStatements;
|
|
- private int _maxRecursionDepth;
|
|
|
|
|
|
+ private int _maxRecursionDepth = -1;
|
|
private TimeSpan _timeoutInterval;
|
|
private TimeSpan _timeoutInterval;
|
|
private CultureInfo _culture = CultureInfo.CurrentCulture;
|
|
private CultureInfo _culture = CultureInfo.CurrentCulture;
|
|
private TimeZoneInfo _localTimeZone = TimeZoneInfo.Local;
|
|
private TimeZoneInfo _localTimeZone = TimeZoneInfo.Local;
|
|
@@ -33,16 +32,6 @@ namespace Jint
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// When called, doesn't allow to use recursion.
|
|
|
|
- /// Can be useful when you can not trust to author of the script and safety has higher priority.
|
|
|
|
- /// </summary>
|
|
|
|
- public Options DiscardRecursion(bool discard = true)
|
|
|
|
- {
|
|
|
|
- _discardRecursion = discard;
|
|
|
|
- return this;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Run the script in strict mode.
|
|
/// Run the script in strict mode.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -97,7 +86,17 @@ namespace Jint
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
- public Options MaxRecursionDepth(int maxRecursionDepth = 0)
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Sets maximum allowed depth of recursion.
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="maxRecursionDepth">
|
|
|
|
+ /// The allowed depth.
|
|
|
|
+ /// a) In case max depth is negative engine ignores stack overflow protection logic;
|
|
|
|
+ /// b) In case max depth is zero no recursion is allowed.
|
|
|
|
+ /// c) In case max depth is equal to n it means that in one scope function can be called no more than n times.
|
|
|
|
+ /// </param>
|
|
|
|
+ /// <returns>Options instance for fluent syntax</returns>
|
|
|
|
+ public Options MaxRecursionDepth(int maxRecursionDepth = -1)
|
|
{
|
|
{
|
|
_maxRecursionDepth = maxRecursionDepth;
|
|
_maxRecursionDepth = maxRecursionDepth;
|
|
return this;
|
|
return this;
|
|
@@ -155,11 +154,6 @@ namespace Jint
|
|
return _maxRecursionDepth;
|
|
return _maxRecursionDepth;
|
|
}
|
|
}
|
|
|
|
|
|
- internal bool IsRecursionAllowed()
|
|
|
|
- {
|
|
|
|
- return !_discardRecursion;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
internal TimeSpan GetTimeoutInterval()
|
|
internal TimeSpan GetTimeoutInterval()
|
|
{
|
|
{
|
|
return _timeoutInterval;
|
|
return _timeoutInterval;
|