Add missing QT_NO_CAST_FROM_ASCII
to QLatin1String's compare operators that takes const char *s or QByteArray. Such comparison leads to a potential misuse since QByteArray could contain any arbitrary data in any arbitrary encoding and QLatin1String is used to only contain strings in UTF-8 - they are just a different beasts aimed for different purposes, and since QT_NO_CAST_*_ASCII disallow indirect conversions and require the user to know what he's doing, let's be consistent here too. Change-Id: I9bf5f326495157db8a6af064d6154961b7861a7e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
72bd1c3228
commit
f19fbcf4e3
|
|
@ -96,6 +96,7 @@ public:
|
|||
inline bool operator>=(const QString &s) const;
|
||||
inline bool operator<=(const QString &s) const;
|
||||
|
||||
#ifndef QT_NO_CAST_FROM_ASCII
|
||||
inline QT_ASCII_CAST_WARN bool operator==(const char *s) const;
|
||||
inline QT_ASCII_CAST_WARN bool operator!=(const char *s) const;
|
||||
inline QT_ASCII_CAST_WARN bool operator<(const char *s) const;
|
||||
|
|
@ -109,6 +110,7 @@ public:
|
|||
inline QT_ASCII_CAST_WARN bool operator>(const QByteArray &s) const;
|
||||
inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &s) const;
|
||||
inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &s) const;
|
||||
#endif // QT_NO_CAST_FROM_ASCII
|
||||
|
||||
private:
|
||||
int m_size;
|
||||
|
|
@ -1049,7 +1051,6 @@ inline bool operator>(QLatin1String s1, QLatin1String s2)
|
|||
inline bool operator>=(QLatin1String s1, QLatin1String s2)
|
||||
{ int r = memcmp(s1.latin1(), s2.latin1(), qMin(s1.size(), s2.size()));
|
||||
return (r > 0) || (r == 0 && s1.size() >= s2.size()); }
|
||||
#endif // QT_NO_CAST_FROM_ASCII
|
||||
|
||||
inline QT_ASCII_CAST_WARN bool QLatin1String::operator==(const char *s) const
|
||||
{ return QString::fromUtf8(s) == *this; }
|
||||
|
|
@ -1077,7 +1078,6 @@ inline QT_ASCII_CAST_WARN bool QLatin1String::operator<=(const QByteArray &s) co
|
|||
inline QT_ASCII_CAST_WARN bool QLatin1String::operator>=(const QByteArray &s) const
|
||||
{ return QString::fromUtf8(s) <= *this; }
|
||||
|
||||
#ifndef QT_NO_CAST_FROM_ASCII
|
||||
inline QT_ASCII_CAST_WARN bool QString::operator==(const QByteArray &s) const
|
||||
{ return QString::compare_helper(constData(), size(), s.constData(), qstrnlen(s.constData(), s.size())) == 0; }
|
||||
inline QT_ASCII_CAST_WARN bool QString::operator!=(const QByteArray &s) const
|
||||
|
|
|
|||
Loading…
Reference in New Issue