Verbs.java silently drops SET with an empty argument
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 82/100
Research direction
Start at src/main/java/org/xembly/Verbs.java lines 182-185, where part.split(String.valueOf(quote), 0) drops trailing empty fields so SET '' yields a single token and simpleCommand() returns an empty optional; changing the limit to -1 should route the empty argument into the existing three-field branch. Read the surrounding parse loop and directives() to confirm the buffered command is then consumed. Add regression tests in the parsing test class covering both quote styles and overwriting existing text, and check the round trip new Directives(new Directives().set("").toString()). Done means the example in the issue returns an empty text content and mvn test passes.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Java
- Stars
- 248
- Forks
- 33
- Avg merge
- 17h 59m
- Merged PRs (30d)
- 46
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
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 yegor256/xembly
-
AddIfDirective.java mistakes processing instructions for elementsPossibly taken @Inf1mum claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
yegor256/xembly#440 · 1 comment ·
Maintainers usually reply within 1 day
-
let's use Xnav instead of `XPathFactory`May be free again @volodya-lombrozo claimed this 634 days ago, and no pull request is open. Openenhancement
yegor256/xembly#246 · 3 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Dependency DashboardPossibly taken @yegor256 claimed this 1 day ago. Openwontfix
Difficulty 5/5 Over a week Newbie friendliness 10/100
yegor256/xembly#111 · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
Maintainers usually reply within 1 day
-
RIS export splits an organization name containing “and” into multiple authorsPossibly taken @Gautam-aman claimed this today. Openstatus: needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JabRef/jabref#17821 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
Maintainers usually reply within 1 day