Skip to content

Commit

Permalink
more work for #549
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Aug 13, 2019
1 parent 598d3c0 commit a954787
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ public JsonFactoryBuilder highestNonEscapedChar(int maxNonEscaped) {
* @param ch Character to use for quoting field names and JSON String values.
*/
public JsonFactoryBuilder quoteChar(char ch) {
// 12-Aug-2019, tatu: Due to implementation details, escaping characters beyond
// 7-bit ASCII set has deep overhead so let's limit set. If we absolutely
// must it is possible of course, but leads to problems combining with
// custom escaping aspects.
if (ch > 0x7F) {
throw new IllegalArgumentException("Can only use Unicode characters up to 0x7F as quote characters");
}
_quoteChar = ch;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ public class CustomQuoteCharTest
.quoteChar('\'')
.build();

// Only ASCII range supported as of 2.10
public void testInvalidQuote() throws Exception
{
try {
streamFactoryBuilder()
.quoteChar('\u00A0');
fail("Should not allow quote character outside ASCII range");
} catch (IllegalArgumentException e) {
verifyException(e, "Can only use Unicode characters up to 0x7F");
}
}

public void testBasicAposWithCharBased() throws Exception
{
StringWriter w;
Expand Down

0 comments on commit a954787

Please sign in to comment.