JSONML decodes text entities twice with keepStrings enabled
まだ誰も着手していません。
評価
調査の方向性
JSONML.parse() から開始し、keepStrings ブランチに注目して、issue が関連するパスとして特定している XMLTokener.nextContent() および XML.unescape() と比較してください。提供されている 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時間
- マージ済み PR(30日)
- 2
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 35/100
stleary/JSON-java の issue をすべて見る
似ている issue
-
P2 testing
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
area/core kind/bug status/triage team/core-shared
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
checkstyle/checkstyle#21755 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
spring-projects/spring-integration#11495 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信