You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
org.json.XML.unescape(" "); throws org.json.JSONException: Invalid numeric character reference: #1059
Alternate form of the issue:
// throws an exception after v20260522, but used to work in v20251224
XML.toJSONObject("<a> </a>");
In XML, the &#...; sequence defines a codepoint, not a numeric value. The codepoint 10 is a linefeed, which is not a valid JSON character. I believe it was fixed correctly in #1045.
However, a mechanism can be provided to support legacy code that relies on the v20251224 behavior, for the special case of codepoints that evaluate to one of the common whitespace chars (TAB, LF, CR). Will this work for you?
is parsed to int 10 and converted to a string containing a linefeed, this value is stripped when trim() is called, so the resulting value is an empty string.
@S-wald What is your use case? Is your code calling XML.unescape() directly?
Activity
stleary commentedon Jun 12, 2026
@S-wald Thanks for submitting this issue.
Alternate form of the issue:
// throws an exception after v20260522, but used to work in v20251224
XML.toJSONObject("
<a> </a>");In XML, the
&#...;sequence defines a codepoint, not a numeric value. The codepoint 10 is a linefeed, which is not a valid JSON character. I believe it was fixed correctly in #1045.However, a mechanism can be provided to support legacy code that relies on the v20251224 behavior, for the special case of codepoints that evaluate to one of the common whitespace chars (TAB, LF, CR). Will this work for you?
S-wald commentedon Jun 12, 2026
@stleary IMHO
org.json.XML.unescapeshould just unescape XML and output the whitespace char (e.g. '\n'). After that it may be escaped for JSON again.stleary commentedon Jun 13, 2026
v20251224 behavior:
Given:
XML.toJSONObject("<a> </a>"); is parsed toint 10and converted to a string containing a linefeed, this value is stripped when trim() is called, so the resulting value is an empty string.@S-wald What is your use case? Is your code calling
XML.unescape()directly?S-wald commentedon Jun 23, 2026
We use
XML.toJSONObjectto convert some XML we get from some other system component.Fix XML.unescape rejecting valid whitespace numeric character references