PiDirective lowercases the PI target, dropping case in violation of the XML spec
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 248
- Forks
- 32
- Avg merge
- 17h 21m
- Merged PRs (30d)
- 27
Description
The constructor of PiDirective lowercases the target name with tgt.toLowerCase(Locale.ENGLISH) before storing it in this.target, see src/main/java/org/xembly/PiDirective.java around line 38. The lowercased value is later used in Document.createProcessingInstruction(this.target.raw(), this.data.raw()) around line 60, so the case information from the caller is lost in the produced DOM.
XML 1.0 Names are case-sensitive, and the PITarget production in section 2.6 inherits that. Calling new Directives().pi("MyApp", "x") ends up emitting <?myapp x?> instead of <?MyApp x?>, which is observably different from what every other XML toolchain produces for the same input. Callers that expect the target they wrote to round-trip through xembly silently get a different document.
The lowercasing looks like it was meant to detect the reserved xml prefix (case-insensitive per the spec), but storing the lowercased form goes further than that and rewrites the user input. The fix is to keep tgt as-is in this.target and, if a check is still wanted, reject targets that match (?i)^xml$ instead of folding the case.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start in src/main/java/org/xembly/PiDirective.java around lines 38 and 60, then reproduce the issue with new Directives().pi("MyApp", "x"). Verify that the processing-instruction target preserves the caller's case and that reserved xml-target handling remains correct; the emitted result should use MyApp rather than myapp.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100