JSONML decodes text entities twice with keepStrings enabled
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
Línea de trabajo
Comience en JSONML.parse(), centrándose en la rama keepStrings, y compárela con XMLTokener.nextContent() y XML.unescape(), que el issue identifica como las rutas relevantes. Reproduzca el ejemplo de Java proporcionado y, después, verifique que keepStrings conserva el nodo de texto como "<" y que convertir de nuevo el resultado a XML conserva el texto original.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
JSONML decodes text nodes twice when keepStrings is enabled. Attributes and the default mode decode the same input once.
Reproduced on release 20260814 and current master (874673575807723d58bbec9ff1985668742940ce), with Java 17.0.20:
import org.json.JSONML;
String xml = "<p title=\"&lt;\">&lt;</p>";
System.out.println(JSONML.toJSONArray(xml, false));
System.out.println(JSONML.toJSONArray(xml, true));
Output:
["p",{"title":"<"},"<"]
["p",{"title":"<"},"<"]
The second result should also contain "<" as its text node. Enabling keepStrings should affect type conversion, not the text itself. toJSONObject(xml, true) has the same behavior, and converting the result back to XML changes the original text.
XMLTokener.nextContent() already decodes entities, but the keepStrings branch in JSONML.parse() calls XML.unescape() again. This looks like a remaining case from #362, which removed the extra decoding for JSONML attributes and the XML conversion paths.
- Lenguaje dominante
- Java
- Estrellas
- 4.7k
- Forks
- 2.6k
- Merge medio
- 11 d 18 min
- PR fusionados (30 d)
- 1
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de stleary/JSON-java
-
Fix before the next release
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
New JSONPointer tests needed Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Fix before the next release
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Active discussion
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Todos los issues de stleary/JSON-java
Issues similares
-
Bug Java Platform: Java
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
getsentry/sentry-java#6138 · 1 comentario ·
-
bug needs triage p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
GoogleCloudPlatform/DataflowTemplates#4273 · 1 comentario ·
-
[Studio][Bug] Bulk-deleting a full page of alert rules steps the page back while more rules remain Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
apache/rocketmq-dashboard#4654 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100