Verbs.java silently drops SET with an empty argument

オープン 初心者向け
#442 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
tooling

調査の方向性

src/main/java/org/xembly/Verbs.java の 182-185 行目から始めてください。ここでは part.split(String.valueOf(quote), 0) が末尾の空フィールドを落とすため、SET '' は単一のトークンになり、simpleCommand() は空の optional を返します。limit を -1 に変更すると、空の引数が既存の3フィールド分岐に振り分けられるはずです。周囲の parse ループと directives() を読み、バッファされたコマンドがその後に消費されることを確認してください。parsing テストクラスに、両方のクォートスタイルと既存テキストの上書きをカバーする回帰テストを追加し、ラウンドトリップ new Directives(new Directives().set("").toString()) を確認してください。完了とは、issue の例が空のテキスト内容を返し、mvn test が通ることを意味します。

索引モデルが issue の本文から書いたものです。

説明

SET '' is silently discarded when parsed from a script, so clearing an element leaves its previous text intact. For example:

Document dom = new Xembler(
    new Directives("ADD 'root'; SET 'keep'; SET '';")
).dom();
// Expected: dom.getDocumentElement().getTextContent().equals("")
// Actual:   dom.getDocumentElement().getTextContent().equals("keep")

In src/main/java/org/xembly/Verbs.java:182–185, splitting with limit zero removes trailing empty strings:

final String[] args = part.split(String.valueOf(quote), 0);
final Optional<Callback<Directive>> cmd;
if (args.length == 1) {
    cmd = Optional.empty();

For SET '', this leaves only the command prefix. simpleCommand() returns an empty optional, and directives() finishes with the buffered command unconsumed. This also breaks the round trip through new Directives(new Directives().set("").toString()); the builder's valid empty value disappears during parsing.

Preserve the trailing fields in simpleCommand() so the existing three-field branch receives the empty argument:

final String[] args = part.split(String.valueOf(quote), -1);

Add regression coverage for both quote styles and for clearing text that is already present.

主要言語
Java
スター
248
フォーク
33
平均マージ
17時間 59分
マージ済み PR(30日)
46

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

yegor256/xembly のほかの issue

yegor256/xembly の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。