fix(serialize-xml): Actually consume header
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
12d345ca20
commit
ca746c05a4
@ -271,6 +271,9 @@ public class NativeXmlReader implements Closeable {
|
||||
} else if (peekStack == XmlScope.TAG_BODY) {
|
||||
// fall through: a new element is starting
|
||||
} else if (peekStack == XmlScope.EMPTY_DOCUMENT) {
|
||||
if (lenient) {
|
||||
consumeHeader();
|
||||
}
|
||||
stack[stackSize - 1] = XmlScope.NONEMPTY_DOCUMENT;
|
||||
// fall through: a new element is starting
|
||||
} else if (peekStack == XmlScope.NONEMPTY_DOCUMENT) {
|
||||
@ -809,6 +812,7 @@ public class NativeXmlReader implements Closeable {
|
||||
// we found a header, consume it
|
||||
pos += 5;
|
||||
skipTo("?>");
|
||||
pos += 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -219,6 +219,19 @@ public final class NativeXmlReaderTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmlHeader() throws IOException {
|
||||
NativeXmlReader reader = new NativeXmlReader(reader("<?xml version=\"1.0\" encoding=\"UTF-8\"?><tag>content</tag>"));
|
||||
assertThrows(IOException.class, reader::peek);
|
||||
reader = new NativeXmlReader(reader("<?xml version=\"1.0\" encoding=\"UTF-8\"?><tag>content</tag>"));
|
||||
reader.setLenient(true);
|
||||
assertThat(reader.peek()).isEqualTo(XmlToken.BEGIN_TAG);
|
||||
assertThat(reader.beginTag()).isEqualTo("tag");
|
||||
assertThat(reader.nextText()).isEqualTo("content");
|
||||
assertThat(reader.endTag()).isEqualTo("tag");
|
||||
assertThat(reader.peek()).isEqualTo(XmlToken.EOF);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// public void testHelloWorld() throws IOException {
|
||||
// String json =
|
||||
|
Loading…
Reference in New Issue
Block a user