AddIfDirective.java mistakes processing instructions for elements
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Start in src/main/java/org/xembly/AddIfDirective.java, lines 53-57, where the child scan compares getNodeName() without checking getNodeType(). Fix the match to require Node.ELEMENT_NODE and confirm the existing creation path then adds the missing element, as shown by AttrDirective.exec() casting the node to Element. Done means the snippet in src/test/java/org/xembly (add a regression case whose PI target equals the requested element name) yields <root><?item data?><item id="1"/></root>. Note pull request #441 is already open on this, so coordinate before starting.
索引モデルが issue の本文から書いたものです。
説明
ADDIF 'item' reuses <?item data?> instead of creating an item element. A following ATTR then throws ClassCastException because its cursor contains a processing instruction.
For example:
new Xembler(
new Directives()
.add("root")
.pi("item", "data")
.addIf("item")
.attr("id", "1")
).dom();
This should produce <root><?item data?><item id="1"/></root>. Instead, ADDIF leaves the element absent and Element.class.cast(node) in AttrDirective.exec() receives the processing instruction.
In src/main/java/org/xembly/AddIfDirective.java, lines 53–57, the lookup compares names without checking the node type:
if (kids.item(idx).getNodeName().equals(this.name.raw())) {
target = kids.item(idx);
break;
}
A processing instruction's node name is its target, so it can match any requested element name. Restrict the match to element nodes:
if (kids.item(idx).getNodeType() == Node.ELEMENT_NODE
&& kids.item(idx).getNodeName().equals(this.name.raw())) {
target = kids.item(idx);
break;
}
This lets the existing creation path add the missing element while preserving the processing instruction. Add a regression case with a PI whose target equals the requested element name; the existing PI coverage uses a different target.
- 主要言語
- Java
- スター
- 248
- フォーク
- 33
- 平均マージ
- 17時間 59分
- マージ済み PR(30日)
- 46
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
yegor256/xembly のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
let's use Xnav instead of `XPathFactory`再び着手できるかも @volodya-lombrozo が 635 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンenhancement
yegor256/xembly#246 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Dependency Dashboard対応中かも @yegor256 が 1 日前に担当しました。 オープンwontfix
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
yegor256/xembly#111 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
yegor256/xembly の issue をすべて見る
似ている issue
-
good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
commons-app/apps-android-commons#7341 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
NationalSecurityAgency/ghidra#10220 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信