aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2023-12-27 16:48:54 +0100
committerJay Berkenbilt <ejb@ql.org>2023-12-27 16:48:54 +0100
commita3b939ce583b925439d3b549780bbdbb68611ea6 (patch)
tree0d6aafde189eaf4b7e8f449650c59cfd89c5a3cf /libqpdf
parentf5a1e2872ee80d4320de91668a992976e0d7168c (diff)
downloadqpdf-a3b939ce583b925439d3b549780bbdbb68611ea6.tar.zst
Tweak utf8 checks
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QUtil.cc12
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;
}
}