JSONML decodes text entities twice with keepStrings enabled
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start in JSONML.parse(), focusing on the keepStrings branch, and compare it with XMLTokener.nextContent() and XML.unescape(), which the issue identifies as the relevant paths. Reproduce the supplied Java example, then verify that keepStrings preserves the text node as "<" and that converting the result back to XML preserves the original text.
Written by the indexing model from the issue text.
Description
JSONML decodes text nodes twice when keepStrings is enabled. Attributes and the default mode decode the same input once.
Reproduced on release 20260814 and current master (874673575807723d58bbec9ff1985668742940ce), with Java 17.0.20:
import org.json.JSONML;
String xml = "<p title=\"&lt;\">&lt;</p>";
System.out.println(JSONML.toJSONArray(xml, false));
System.out.println(JSONML.toJSONArray(xml, true));
Output:
["p",{"title":"<"},"<"]
["p",{"title":"<"},"<"]
The second result should also contain "<" as its text node. Enabling keepStrings should affect type conversion, not the text itself. toJSONObject(xml, true) has the same behavior, and converting the result back to XML changes the original text.
XMLTokener.nextContent() already decodes entities, but the keepStrings branch in JSONML.parse() calls XML.unescape() again. This looks like a remaining case from #362, which removed the extra decoding for JSONML attributes and the XML conversion paths.
- Dominant language
- Java
- Stars
- 4.7k
- Forks
- 2.6k
- Avg merge
- 6d 20h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stleary/JSON-java
-
Fix before the next release
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Fix before the next release
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Active discussion
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in stleary/JSON-java
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100