diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-02-18 18:13:08 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-03-04 08:04:01 +0100 |
commit | 3c4c8b61aa374baf67ca91a8fc5f7ada0061fa12 (patch) | |
tree | c64988e53751570756b815e7cd1a16dbb408b691 /src | |
parent | 04cc5befd67e78ed90f4632532e8ca1dfd43675b (diff) |
QStringConverter: make name matching locale-independent
The existing name lookup code used C's toupper() function for
case-insensitive comparison. However, that function's result depends
on the current locale.
Since the matcher is supposed to match the likes of "iso-8859-1" and
"latin-1", matching may fail in locales, such as Turkish, where
toupper(i) is İ (or i, if the former isn't representable in the current
charset), but toupper(I) remains I, causing a False Negative.
To fix, use the US-ASCII-only QtMiscUtils::toAsciiLower() function,
which has the added advantage that it's inline.
Change-Id: I70613c0167d84e3dc3d282c61c716b5dd0b3e6bb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 955106c4fbc3769c646beb99ed91dadff14ec2d2)
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/text/qstringconverter.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index 83cbc3095a..e6c2552348 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -44,6 +44,7 @@ #include "private/qsimd_p.h" #include "private/qstringiterator_p.h" +#include "private/qtools_p.h" #include "qbytearraymatcher.h" #ifdef Q_OS_WIN @@ -1671,7 +1672,7 @@ static bool nameMatch(const char *a, const char *b) ++b; continue; } - if (toupper(*a) != toupper(*b)) + if (QtMiscUtils::toAsciiLower(*a) != QtMiscUtils::toAsciiLower(*b)) return false; ++a; ++b; |