JSONML decodes text entities twice with keepStrings enabled
還沒有人認領這個 Issue。
評估
研究方向
從 JSONML.parse() 開始,著重檢視 keepStrings 分支,並將其與 XMLTokener.nextContent() 和 XML.unescape() 比較,issue 將它們識別為相關路徑。重現所提供的 Java 範例,然後驗證 keepStrings 會將文字節點保留為 "<",以及將結果轉回 XML 後仍會保留原始文字。
由索引模型根據 Issue 內容生成。
描述
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.
- 主要語言
- Java
- 星號
- 4.7k
- 分支
- 2.6k
- 平均合併
- 6 天 20 小時
- 30 天內合併 PR
- 2
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
stleary/JSON-java 的其他 Issue
-
Fix before the next release
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 2/5 1-3 小時 新手友好度 76/100
-
難度 2/5 1-3 小時 新手友好度 88/100
-
Fix before the next release
難度 2/5 1-3 小時 新手友好度 78/100
-
Active discussion
難度 5/5 一週以上 新手友好度 35/100
查看 stleary/JSON-java 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
infinispan/infinispan#18150 ·
-
難度 2/5 1-3 小時 新手友好度 84/100
-
untriaged
難度 2/5 1-3 小時 新手友好度 82/100
opensearch-project/k-NN#3597 ·
-
bug
難度 2/5 1-3 小時 新手友好度 88/100
-
bug
難度 2/5 1-3 小時 新手友好度 82/100