mirror of
https://github.com/libexpat/libexpat.git
synced 2025-04-13 08:02:56 +00:00
Check UTF-16 endianness matches (Issue #86)
When an XML declaration specifies a UTF-16 encoding, check that the endianness matches what the parser has already deduced.
This commit is contained in:
parent
611bf03530
commit
7eb3cbcec6
1 changed files with 8 additions and 1 deletions
|
@ -3977,7 +3977,14 @@ processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
|
|||
reportDefault(parser, encoding, s, next);
|
||||
if (protocolEncodingName == NULL) {
|
||||
if (newEncoding) {
|
||||
if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) {
|
||||
/* Check that the specified encoding does not conflict with what
|
||||
* the parser has already deduced. Do we have the same number
|
||||
* of bytes in the smallest representation of a character? If
|
||||
* this is UTF-16, is it the same endianness?
|
||||
*/
|
||||
if (newEncoding->minBytesPerChar != encoding->minBytesPerChar
|
||||
|| (newEncoding->minBytesPerChar == 2 &&
|
||||
newEncoding != encoding)) {
|
||||
eventPtr = encodingName;
|
||||
return XML_ERROR_INCORRECT_ENCODING;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue