fix(serialize-xml): Actually consume header
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
12d345ca20
commit
ca746c05a4
|
@ -271,6 +271,9 @@ public class NativeXmlReader implements Closeable {
|
||||||
} else if (peekStack == XmlScope.TAG_BODY) {
|
} else if (peekStack == XmlScope.TAG_BODY) {
|
||||||
// fall through: a new element is starting
|
// fall through: a new element is starting
|
||||||
} else if (peekStack == XmlScope.EMPTY_DOCUMENT) {
|
} else if (peekStack == XmlScope.EMPTY_DOCUMENT) {
|
||||||
|
if (lenient) {
|
||||||
|
consumeHeader();
|
||||||
|
}
|
||||||
stack[stackSize - 1] = XmlScope.NONEMPTY_DOCUMENT;
|
stack[stackSize - 1] = XmlScope.NONEMPTY_DOCUMENT;
|
||||||
// fall through: a new element is starting
|
// fall through: a new element is starting
|
||||||
} else if (peekStack == XmlScope.NONEMPTY_DOCUMENT) {
|
} else if (peekStack == XmlScope.NONEMPTY_DOCUMENT) {
|
||||||
|
@ -809,6 +812,7 @@ public class NativeXmlReader implements Closeable {
|
||||||
// we found a header, consume it
|
// we found a header, consume it
|
||||||
pos += 5;
|
pos += 5;
|
||||||
skipTo("?>");
|
skipTo("?>");
|
||||||
|
pos += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
// @Test
|
||||||
// public void testHelloWorld() throws IOException {
|
// public void testHelloWorld() throws IOException {
|
||||||
// String json =
|
// String json =
|
||||||
|
|
Loading…
Reference in New Issue