AddIfDirective.java mistakes processing instructions for elements
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Java
- Stelle
- 248
- Fork
- 33
- Merge medio
- 17h 59m
- PR unite (30g)
- 46
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di yegor256/xembly
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
let's use Xnav instead of `XPathFactory`Forse di nuovo libera @volodya-lombrozo l’ha presa 634 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
yegor256/xembly#246 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Dependency DashboardForse già presa @yegor256 l’ha presa 1 giorno fa. Apertawontfix
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
yegor256/xembly#111 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di yegor256/xembly
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
NationalSecurityAgency/ghidra#10220 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
RIS export splits an organization name containing “and” into multiple authorsForse già presa @Gautam-aman l’ha presa oggi. Apertastatus: needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
JabRef/jabref#17821 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
FailureContext.java rounds down thresholds in lastedAtLeast()Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno