From 12aec5bfda2d93f79643f88af5ded9612b532405 Mon Sep 17 00:00:00 2001 From: JFronny Date: Sat, 20 Apr 2024 23:18:24 +0200 Subject: [PATCH] fix(serialize-xml): Don't require ending semicolon of reference when lenient in NativeXmlReader --- .../serialize/xml/NativeXmlReader.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/NativeXmlReader.java b/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/NativeXmlReader.java index 7c5bd4e..faaa7d3 100644 --- a/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/NativeXmlReader.java +++ b/commons-serialize-xml/src/main/java/io/gitlab/jfronny/commons/serialize/xml/NativeXmlReader.java @@ -378,14 +378,18 @@ public class NativeXmlReader implements Closeable { // read the entity reference // we don't support these, so just handle them like a normal string String result = nextName(); - if (buffer[pos] != ';') throw syntaxError("Missing ';' in entity reference"); - pos++; - if (result.equals("apos")) return "'"; - if (result.equals("quot")) return "\""; - if (result.equals("amp")) return "&"; - if (result.equals("lt")) return "<"; - if (result.equals("gt")) return ">"; - return "&" + result + ";"; + if (buffer[pos] != ';') { + if (!lenient) throw syntaxError("Missing ';' in entity reference"); + return "&" + result; + } else { + pos++; + if (result.equals("apos")) return "'"; + if (result.equals("quot")) return "\""; + if (result.equals("amp")) return "&"; + if (result.equals("lt")) return "<"; + if (result.equals("gt")) return ">"; + return "&" + result + ";"; + } } }