summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-12-20 14:13:36 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-12-22 07:50:48 +0000
commit3172695838372b54c2a488975578eaedaf094e80 (patch)
tree255318e0176e39470e0a65af3bf284ef5d81c9cc /src
parentcc5ec3fdf902c069a3e790638f4ee82646e30e75 (diff)
QPdfDocument: make code locale-independent
The C toupper/tolower functions are locale-dependent. Given the right locale (Türkiye, e.g.), tolower(I) is either - ı (LATIN SMALL LETTER DOTLESS I; if representable in current charset) - I (unchanged; if it isn't) Both results are wrong for the present use-case, so use US-ASCII-only QtMiscUtils::toAsciiLower() to side-step the issue. Besides, feeding unfiltered char values into tolower() is UB. You'd first have to cast to uchar: https://en.cppreference.com/w/cpp/string/byte/tolower Task-number: QTBUG-109235 Pick-to: 6.5 6.4 Change-Id: I57887581ba2e548e978223337d681124b30bf754 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/pdf/qpdfdocument.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pdf/qpdfdocument.cpp b/src/pdf/qpdfdocument.cpp
index 9b8d20d3b..a3e412c5c 100644
--- a/src/pdf/qpdfdocument.cpp
+++ b/src/pdf/qpdfdocument.cpp
@@ -17,6 +17,8 @@
#include <QMutex>
#include <QVector2D>
+#include <QtCore/private/qtools_p.h>
+
QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QRecursiveMutex, pdfMutex)
@@ -39,7 +41,7 @@ public:
QMetaEnum rolesMetaEnum = doc->metaObject()->enumerator(doc->metaObject()->indexOfEnumerator("PageModelRole"));
for (int r = Qt::UserRole; r < int(QPdfDocument::PageModelRole::NRoles); ++r) {
auto name = QByteArray(rolesMetaEnum.valueToKey(r));
- name[0] = tolower(name[0]);
+ name[0] = QtMiscUtils::toAsciiLower(name[0]);
m_roleNames.insert(r, name);
}
connect(doc, &QPdfDocument::statusChanged, this, [this](QPdfDocument::Status s) {