fix(serialize-xml): look at the right places in the buffer

This commit is contained in:
Johannes Frohnmeyer 2024-04-13 19:32:27 +02:00
parent eb3db63fd5
commit 264f847cdf
Signed by: Johannes
GPG Key ID: E76429612C2929F4
1 changed files with 6 additions and 6 deletions

View File

@ -263,13 +263,13 @@ public class BaseXmlReader implements Closeable {
if (c == -1) {
throw syntaxError("Unterminated tag");
} else if (c == '<') {
if (pos + 1 <= limit || fillBuffer(2)) {
char chNext = buffer[pos + 1];
if (pos + 1 <= limit || fillBuffer(1)) {
char chNext = buffer[pos];
if (chNext == '/') {
pos++;
return peeked = PEEKED_END_TAG;
} else if (chNext == '!') {
if (pos + 8 <= limit || fillBuffer(9)) {
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;
return peeked = PEEKED_CDATA;
@ -277,15 +277,15 @@ public class BaseXmlReader implements Closeable {
throw syntaxError("Expected <![CDATA[ but was <![" + new String(buffer, pos, 5));
}
}
} else if (pos + 2 >= limit || fillBuffer(3)) {
var check = isNameStart(chNext, buffer[pos + 2]);
} 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 at " + c);
throw syntaxError("Unterminated tag");
} else {
return peeked = PEEKED_TEXT;
}