-Added CheckAdditionalContent to JsonSerializer/JsonSerializerSettings
-Fixed bad JSON in an array with error handling creating an infinite loop -JsonTextReader no longer returns no content after consecutive underlying content read failures
This commit is contained in:
@@ -55,8 +55,6 @@ namespace Newtonsoft.Json
|
||||
private const char UnicodeReplacementChar = '\uFFFD';
|
||||
|
||||
private readonly TextReader _reader;
|
||||
private int _readerFailureCount;
|
||||
|
||||
private char[] _chars;
|
||||
private int _charsUsed;
|
||||
private int _charPos;
|
||||
@@ -76,10 +74,7 @@ namespace Newtonsoft.Json
|
||||
throw new ArgumentNullException("reader");
|
||||
|
||||
_reader = reader;
|
||||
_readerFailureCount = 0;
|
||||
|
||||
_lineNumber = 1;
|
||||
|
||||
_chars = new char[4097];
|
||||
}
|
||||
|
||||
@@ -326,25 +321,7 @@ namespace Newtonsoft.Json
|
||||
|
||||
int attemptCharReadCount = _chars.Length - _charsUsed - 1;
|
||||
|
||||
int charsRead;
|
||||
|
||||
try
|
||||
{
|
||||
charsRead = _reader.Read(_chars, _charsUsed, attemptCharReadCount);
|
||||
_readerFailureCount = 0;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// to prevent infinate loop when error handling is enabled
|
||||
if (!_isEndOfFile)
|
||||
{
|
||||
_readerFailureCount++;
|
||||
if (_readerFailureCount >= 3)
|
||||
_isEndOfFile = true;
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
int charsRead = _reader.Read(_chars, _charsUsed, attemptCharReadCount);
|
||||
|
||||
_charsUsed += charsRead;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user