fix(serialize-xml): prevent overzealous null

This commit is contained in:
Johannes Frohnmeyer 2024-04-20 16:42:39 +02:00
parent 45eee07a29
commit 8992e42393
Signed by: Johannes
GPG Key ID: E76429612C2929F4
2 changed files with 15 additions and 0 deletions

View File

@ -190,6 +190,20 @@ public class NativeXmlReader implements Closeable {
return p != PEEKED_EOF && p != PEEKED_END_TAG && p != PEEKED_END_TAG_CONCISE;
}
public boolean isConciseEndTag() throws IOException {
int p = peeked;
if (p == PEEKED_NONE) {
p = doPeek();
}
if (p == PEEKED_END_TAG_CONCISE) {
return true;
} else if (p == PEEKED_END_TAG) {
return false;
} else {
throw unexpectedTokenError("END_TAG");
}
}
public XmlToken peek() throws IOException {
int p = peeked;
if (p == PEEKED_NONE) {

View File

@ -263,6 +263,7 @@ public class XmlReader extends SerializeReader<IOException, XmlReader> implement
yield doPeek();
}
case WrapperScope.OBJECT_VALUE_WRAPPER -> {
if (!reader.isConciseEndTag()) throw syntaxError("Unexpected end tag");
stackSize--;
reader.endTag();
yield PEEKED_NULL_VIRTUAL;