Skip to content

Commit

Permalink
Change MaxDepth default to 64 (#2473)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Feb 21, 2021
1 parent 15525f1 commit b6dc05b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs
Expand Up @@ -8000,10 +8000,10 @@ public void NullableDoubleEmptyValue()
public void SetMaxDepth_DepthExceeded()
{
JsonTextReader reader = new JsonTextReader(new StringReader("[[['text']]]"));
Assert.AreEqual(128, reader.MaxDepth);
Assert.AreEqual(64, reader.MaxDepth);

JsonSerializerSettings settings = new JsonSerializerSettings();
Assert.AreEqual(128, settings.MaxDepth);
Assert.AreEqual(64, settings.MaxDepth);
Assert.AreEqual(false, settings._maxDepthSet);

// Default should be the same
Expand Down Expand Up @@ -8034,7 +8034,7 @@ public void SetMaxDepth_DepthNotExceeded()

serializer.Deserialize(reader);

Assert.AreEqual(128, reader.MaxDepth);
Assert.AreEqual(64, reader.MaxDepth);
}
}
}
2 changes: 1 addition & 1 deletion Src/Newtonsoft.Json/JsonReader.cs
Expand Up @@ -329,7 +329,7 @@ protected JsonReader()
_dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind;
_dateParseHandling = DateParseHandling.DateTime;
_floatParseHandling = FloatParseHandling.Double;
_maxDepth = 128;
_maxDepth = 64;

CloseInput = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Src/Newtonsoft.Json/JsonSerializerSettings.cs
Expand Up @@ -61,7 +61,7 @@ public class JsonSerializerSettings
internal static readonly CultureInfo DefaultCulture;
internal const bool DefaultCheckAdditionalContent = false;
internal const string DefaultDateFormatString = @"yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK";
internal const int DefaultMaxDepth = 128;
internal const int DefaultMaxDepth = 64;

internal Formatting? _formatting;
internal DateFormatHandling? _dateFormatHandling;
Expand Down

0 comments on commit b6dc05b

Please sign in to comment.