fix(serialize-xml): more buffer fixes
This commit is contained in:
parent
866b429155
commit
b004c00fcf
|
@ -9,7 +9,6 @@ import java.io.IOException;
|
|||
import java.io.Reader;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.function.IntPredicate;
|
||||
|
||||
public class BaseXmlReader implements Closeable {
|
||||
private static final int PEEKED_NONE = 0;
|
||||
|
@ -150,10 +149,6 @@ public class BaseXmlReader implements Closeable {
|
|||
throw unexpectedTokenError("BEGIN_TAG");
|
||||
}
|
||||
String name = nextName();
|
||||
if (buffer[pos] != '>') {
|
||||
throw syntaxError("Expected > but was " + buffer[pos]);
|
||||
}
|
||||
pos++;
|
||||
pathNames[stackSize - 1] = name;
|
||||
push(XmlScope.TAG_HEAD);
|
||||
peeked = PEEKED_NONE;
|
||||
|
@ -229,6 +224,9 @@ public class BaseXmlReader implements Closeable {
|
|||
} else {
|
||||
throw syntaxError("Unterminated tag at " + c);
|
||||
}
|
||||
} else if (c == '>') {
|
||||
stack[stackSize - 1] = XmlScope.TAG_BODY;
|
||||
// fall through
|
||||
} else if (pos < limit || fillBuffer(1)) {
|
||||
char chNext = buffer[pos + 1];
|
||||
var check = isNameStart((char) c, chNext);
|
||||
|
@ -279,9 +277,9 @@ public class BaseXmlReader implements Closeable {
|
|||
pos++;
|
||||
return peeked = PEEKED_END_TAG;
|
||||
} else if (chNext == '!') {
|
||||
if (pos + 9 <= limit || fillBuffer(9)) {
|
||||
if (buffer[pos + 2] == '[' && buffer[pos + 3] == 'C' && buffer[pos + 4] == 'D' && buffer[pos + 5] == 'A' && buffer[pos + 6] == 'T' && buffer[pos + 7] == 'A' && buffer[pos + 8] == '[') {
|
||||
pos += 9;
|
||||
if (pos + 8 <= limit || fillBuffer(8)) {
|
||||
if (buffer[pos + 1] == '[' && buffer[pos + 2] == 'C' && buffer[pos + 3] == 'D' && buffer[pos + 4] == 'A' && buffer[pos + 5] == 'T' && buffer[pos + 6] == 'A' && buffer[pos + 7] == '[') {
|
||||
pos += 8;
|
||||
return peeked = PEEKED_CDATA;
|
||||
} else {
|
||||
throw syntaxError("Expected <![CDATA[ but was <![" + new String(buffer, pos, 5));
|
||||
|
@ -290,13 +288,13 @@ public class BaseXmlReader implements Closeable {
|
|||
} else if (pos + 2 <= limit || fillBuffer(2)) {
|
||||
var check = isNameStart(chNext, buffer[pos + 1]);
|
||||
if (check != NameCheck.NONE) {
|
||||
pos++;
|
||||
return peeked = PEEKED_BEGIN_TAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw syntaxError("Unterminated tag");
|
||||
} else {
|
||||
pos--;
|
||||
return peeked = PEEKED_TEXT;
|
||||
}
|
||||
}
|
||||
|
@ -474,6 +472,7 @@ public class BaseXmlReader implements Closeable {
|
|||
if (pos + 2 < limit || fillBuffer(3)) {
|
||||
if (buffer[pos] == ']' && buffer[pos + 1] == ']' && buffer[pos + 2] == '>') {
|
||||
pos += 3;
|
||||
peeked = PEEKED_NONE;
|
||||
return sb.toString();
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue