AddIfDirective matches existing children case-insensitively, conflating differently-cased element names
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
The bug is in AddIfDirective.java, specifically in the exec method where it compares node names case-insensitively. Start by locating the file in the codebase, examine the comparison logic, and change it to a case-sensitive check. Run the provided reproduction test to verify the fix creates distinct 'Item' and 'item' elements.
Written by the indexing model from the issue text.
Description
Element names in Xembly are now created and preserved with their original case (issue #31 about forced lowercasing was fixed long ago). However, AddIfDirective still looks for an already-existing child using a case-insensitive comparison, so it can silently reuse a differently-cased sibling instead of creating the element it was asked for, and subsequent directives then modify the wrong node.
Code (AddIfDirective.java, exec):
if (kids.item(idx).getNodeName()
.compareToIgnoreCase(this.name.raw()) == 0) {
target = kids.item(idx);
break;
}
Steps to reproduce
Directives d = new Directives("ADD \x27root\x27; ADD \x27Item\x27; UP; ADDIF \x27item\x27; ATTR \x27marker\x27, \x27yes\x27;");
org.w3c.dom.Document dom = new Xembler(d).dom();
Actual result
<root><Item marker="yes"/></root>
ADDIF "item" found the existing Item element (capital I) via the case-insensitive comparison, reused it as the target, and the following ATTR directive set marker on Item instead of creating a new, separate item element.
Expected result
Since XML element names are case-sensitive and Xembly itself preserves the case a caller gives it when creating elements, ADDIF "item" should not treat the existing Item element as a match. It should create a new item element (so both Item and item exist as distinct siblings), the same way AddDirective and every other part of the library now treats names as case-sensitive.
- Dominant language
- Java
- Stars
- 248
- Forks
- 32
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 37
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
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
yegor256/xembly#305 · 1 comment ·
Maintainers usually reply within 1 day
-
let's use Xnav instead of `XPathFactory`May be free again @volodya-lombrozo claimed this 625 days ago, and no pull request is open. Openenhancement
yegor256/xembly#246 · 3 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Dependency DashboardOpenwontfix
Difficulty 5/5 Over a week Newbie friendliness 10/100
Maintainers usually reply within 1 day
-
standalone=noMay be free again A pull request for this issue was closed without being merged. OpenDEV enhancement
Difficulty 3/5 1-2 days Newbie friendliness 35/100
yegor256/xembly#53 · 6 comments ·
Maintainers usually reply within 1 day
Similar issues
-
Type: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
MCP add-on: JSON responses with non-ASCII characters are truncated (wrong Content-Length)Possibly taken @dhanushbs10 claimed this today. Openadd-on bug in:mcp
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Map.Coordinate does not implement proper equalsPossibly taken A pull request linked to this issue is open or already merged. Openvaadin-map
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vaadin/flow-components#10586 ·
Maintainers usually reply within 1 day
-
WeReadInstaller writes the launcher database on the main thread at handover (Activity pause timeout)Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
wpilibsuite/SystemcoreTesting#446 ·
Maintainers usually reply within 1 day