Skip to content

Commit 46d795a

Browse files
committed
Don't throw DeserializationException for U+007F to U+009F
These are acceptable characters per RFC4627 section 2.5: > All Unicode characters may be placed within the > quotation marks except for the characters that must be escaped: > quotation mark, reverse solidus, and the control characters (U+0000 > through U+001F).
1 parent 3fa7bc3 commit 46d795a

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/JsonFx.Tests/Json/JsonTokenizerTests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,22 @@ public void GetTokens_StringEscapedChars_ReturnsStringToken()
425425
Assert.Equal(expected, actual);
426426
}
427427

428+
[Fact]
429+
[Trait(TraitName, TraitValue)]
430+
public void GetTokens_HighControl_Accepted()
431+
{
432+
const string input = "\"\u0082\"";
433+
var expected = new []
434+
{
435+
ModelGrammar.TokenPrimitive("\u0082")
436+
};
437+
438+
var tokenizer = new JsonReader.JsonTokenizer();
439+
var actual = tokenizer.GetTokens(input).ToArray();
440+
441+
Assert.Equal(expected, actual);
442+
}
443+
428444
[Fact]
429445
[Trait(TraitName, TraitValue)]
430446
public void GetTokens_StringImproperlyEscapedChars_ReturnsStringTokenWithSimpleChars()

src/JsonFx/Utils/CharUtility.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ public static bool IsWhiteSpace(char ch)
8888
/// <returns></returns>
8989
public static bool IsControl(char ch)
9090
{
91-
return
92-
(ch <= '\u001F') ||
93-
((ch >= '\u007F') && (ch <= '\u009F'));
91+
return (ch <= '\u001F');
9492
}
9593

9694
/// <summary>

0 commit comments

Comments
 (0)