mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 04:29:30 -10:00
LibXML: Iterate over code points in Parser::parse_internal()
`s_restricted_characters` contains code points, not UTF-8 bytes. Previously, LibXML errored out on the string '中文' since it contains the byte 0x96, which is in the restricted char set. But this only happened on ABIs where char is signed as this UTF-8 byte had the most significant bit set, therefore the comparison was never true for bytes >= 0x80. Since `Utf8CodePointIterator::index()` doesn't exist, the byte offset is now calculated using `it.ptr() - view.bytes()`. This makes LibXML/TestParser pass on non-x86.
This commit is contained in:
1 parent
ae51627668
commit
bdfa78e487
1 file changed
+3
-2
@@ -221,9 +221,10 @@ ErrorOr<void, ParseError> Parser::parse_internal()
|
||||
}
|
||||
|
||||
auto matched_source = m_source.substring_view(0, m_lexer.tell());
|
||||
if (auto it = find_if(matched_source.begin(), matched_source.end(), s_restricted_characters); !it.is_end()) {
|
||||
Utf8View view { matched_source };
|
||||
if (auto it = find_if(view.begin(), view.end(), s_restricted_characters); it != view.end()) {
|
||||
return parse_error(
|
||||
m_lexer.position_for(it.index()),
|
||||
m_lexer.position_for(it.ptr() - view.bytes()),
|
||||
ByteString::formatted("Invalid character #{:x} used in document", *it));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user