mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 01:59:14 +03:00
AK: Log UTF-8 validation errors
This commit is contained in:
parent
c379f43d2a
commit
55197ed4ef
Notes:
sideshowbarker
2024-07-19 12:16:20 +09:00
Author: https://github.com/bugaevc Commit: https://github.com/SerenityOS/serenity/commit/55197ed4ef1 Pull-request: https://github.com/SerenityOS/serenity/pull/520 Reviewed-by: https://github.com/awesomekling
@ -1,4 +1,5 @@
|
||||
#include <AK/Utf8View.h>
|
||||
#include <AK/LogStream.h>
|
||||
|
||||
namespace AK {
|
||||
|
||||
@ -134,7 +135,13 @@ u32 Utf8CodepointIterator::operator*() const
|
||||
int codepoint_length_in_bytes;
|
||||
|
||||
bool first_byte_makes_sense = decode_first_byte(m_ptr[0], codepoint_length_in_bytes, codepoint_value_so_far);
|
||||
if (!first_byte_makes_sense) {
|
||||
dbg() << "First byte doesn't make sense, bytes = " << (const char*)m_ptr;
|
||||
}
|
||||
ASSERT(first_byte_makes_sense);
|
||||
if (codepoint_length_in_bytes > m_length) {
|
||||
dbg() << "Not enough bytes (need " << codepoint_length_in_bytes << ", have " << m_length << "), first byte is: " << m_ptr[0] << " " << (const char*)m_ptr;
|
||||
}
|
||||
ASSERT(codepoint_length_in_bytes <= m_length);
|
||||
|
||||
for (int offset = 1; offset < codepoint_length_in_bytes; offset++) {
|
||||
|
Loading…
Reference in New Issue
Block a user