Skip to content

Commit a954787

Browse files
committed
more work for #549
1 parent 598d3c0 commit a954787

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/main/java/com/fasterxml/jackson/core/JsonFactoryBuilder.java

+7
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,13 @@ public JsonFactoryBuilder highestNonEscapedChar(int maxNonEscaped) {
198198
* @param ch Character to use for quoting field names and JSON String values.
199199
*/
200200
public JsonFactoryBuilder quoteChar(char ch) {
201+
// 12-Aug-2019, tatu: Due to implementation details, escaping characters beyond
202+
// 7-bit ASCII set has deep overhead so let's limit set. If we absolutely
203+
// must it is possible of course, but leads to problems combining with
204+
// custom escaping aspects.
205+
if (ch > 0x7F) {
206+
throw new IllegalArgumentException("Can only use Unicode characters up to 0x7F as quote characters");
207+
}
201208
_quoteChar = ch;
202209
return this;
203210
}

src/test/java/com/fasterxml/jackson/core/json/CustomQuoteCharTest.java

+12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ public class CustomQuoteCharTest
1212
.quoteChar('\'')
1313
.build();
1414

15+
// Only ASCII range supported as of 2.10
16+
public void testInvalidQuote() throws Exception
17+
{
18+
try {
19+
streamFactoryBuilder()
20+
.quoteChar('\u00A0');
21+
fail("Should not allow quote character outside ASCII range");
22+
} catch (IllegalArgumentException e) {
23+
verifyException(e, "Can only use Unicode characters up to 0x7F");
24+
}
25+
}
26+
1527
public void testBasicAposWithCharBased() throws Exception
1628
{
1729
StringWriter w;

0 commit comments

Comments
 (0)