You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assume you have a cdata section with the following content
This is a ]] > test.
(This is how Atlassian Confluence "escapes" end of CDATA within a CDATA section).
If you write this sequence using XMLStreamWriter2.writeCdata you'll the the following section in the output file
This is a ] > test.
Also the initial sequence should be fine from XML point of view.
Reason
Inside ByteXmlWriter.writeCDataContents each character is checked and written to output. If it comes to a ] character it checks the next character for another ] and a finally a >. In this case the end sequence is properly handled.
In case that any other character after the second ] is detected, it will continue writing characters but without writing the first ] character to the output buffer. So it gets lost.
Solution
The other case (no > character follows the double ]) must be properly handled by writing the first detected ] to the output as well:
(line 851)
if (offset < len && cbuf[offset] == ']') {
if ((offset+1) < len && cbuf[offset+1] == '>') {
// Ok, need to output ']]' first, then end
offset += 2;
writeRaw(BYTE_RBRACKET, BYTE_RBRACKET);
writeCDataEnd();
// Then new start, and '>'
writeCDataStart();
writeRaw(BYTE_GT);
}
else {
// no end found, write first bracket
if (_outputPtr >= _outputBufferLen) {
flushBuffer();
}
_outputBuffer[_outputPtr++] = (byte) ch;
}
continue main_loop;
}
The text was updated successfully, but these errors were encountered:
lepokle
added a commit
to lepokle/aalto-xml
that referenced
this issue
Nov 6, 2024
Problem
Assume you have a cdata section with the following content
(This is how Atlassian Confluence "escapes" end of CDATA within a CDATA section).
If you write this sequence using
XMLStreamWriter2.writeCdata
you'll the the following section in the output fileAlso the initial sequence should be fine from XML point of view.
Reason
Inside
ByteXmlWriter.writeCDataContents
each character is checked and written to output. If it comes to a]
character it checks the next character for another]
and a finally a>
. In this case the end sequence is properly handled.In case that any other character after the second
]
is detected, it will continue writing characters but without writing the first]
character to the output buffer. So it gets lost.Solution
The other case (no
>
character follows the double]
) must be properly handled by writing the first detected]
to the output as well:(line 851)
The text was updated successfully, but these errors were encountered: