diff options
author | Jay Berkenbilt <ejb@ql.org> | 2023-12-27 16:48:54 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2023-12-27 16:48:54 +0100 |
commit | a3b939ce583b925439d3b549780bbdbb68611ea6 (patch) | |
tree | 0d6aafde189eaf4b7e8f449650c59cfd89c5a3cf /libqpdf/QUtil.cc | |
parent | f5a1e2872ee80d4320de91668a992976e0d7168c (diff) | |
download | qpdf-a3b939ce583b925439d3b549780bbdbb68611ea6.tar.zst |
Tweak utf8 checks
Diffstat (limited to 'libqpdf/QUtil.cc')
-rw-r--r-- | libqpdf/QUtil.cc | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/libqpdf/QUtil.cc b/libqpdf/QUtil.cc index 25c7281f..7b4b119b 100644 --- a/libqpdf/QUtil.cc +++ b/libqpdf/QUtil.cc @@ -1825,16 +1825,12 @@ QUtil::analyze_encoding( bool any_errors = false; while (pos < len) { bool error = false; - auto old_pos = pos; - unsigned long codepoint = get_next_utf8_codepoint(val, pos, error); + auto o_pos = pos; + get_next_utf8_codepoint(val, pos, error); if (error) { any_errors = true; - for (auto p = old_pos; p < pos; p++) { - if (static_cast<unsigned char>(val.at(p)) >= 128) { - has_8bit_chars = true; - } - } - } else if (codepoint >= 128) { + } + if (pos - o_pos > 1 || val[o_pos] & 0x80) { has_8bit_chars = true; } } |