mirror of
https://github.com/stleary/JSON-java.git
synced 2026-05-20 00:00:59 -04:00
Validate XML numeric character references before string construction
This commit is contained in:
@@ -1468,6 +1468,42 @@ public class XMLTest {
|
||||
XML.toJSONObject(xmlStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that out-of-range hex entities throw JSONException rather than an uncaught runtime exception.
|
||||
*/
|
||||
@Test(expected = JSONException.class)
|
||||
public void testOutOfRangeHexEntityThrowsJSONException() {
|
||||
String xmlStr = "<a>�</a>";
|
||||
XML.toJSONObject(xmlStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that out-of-range decimal entities throw JSONException rather than an uncaught runtime exception.
|
||||
*/
|
||||
@Test(expected = JSONException.class)
|
||||
public void testOutOfRangeDecimalEntityThrowsJSONException() {
|
||||
String xmlStr = "<a>�</a>";
|
||||
XML.toJSONObject(xmlStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that surrogate code point entities throw JSONException.
|
||||
*/
|
||||
@Test(expected = JSONException.class)
|
||||
public void testSurrogateHexEntityThrowsJSONException() {
|
||||
String xmlStr = "<a>�</a>";
|
||||
XML.toJSONObject(xmlStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that out-of-range numeric entities in attribute values throw JSONException.
|
||||
*/
|
||||
@Test(expected = JSONException.class)
|
||||
public void testOutOfRangeHexEntityInAttributeThrowsJSONException() {
|
||||
String xmlStr = "<a b=\"�\"/>";
|
||||
XML.toJSONObject(xmlStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that valid decimal numeric entity A works correctly.
|
||||
* Should decode to character 'A'.
|
||||
|
||||
Reference in New Issue
Block a user