QSpinBox: don't allow series of thousands-separator chars when editing
The input validation did not check for unreasonable use of the group separator character. Fixes: QTBUG-65024 Change-Id: If9d70d990fc6d5b298f3bde5b1604bf7e16dce24 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
60f5329854
commit
1cc30fe77d
@ -1134,12 +1134,16 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,
|
|||||||
num = copy.toInt(&ok, displayIntegerBase);
|
num = copy.toInt(&ok, displayIntegerBase);
|
||||||
} else {
|
} else {
|
||||||
num = locale.toInt(copy, &ok);
|
num = locale.toInt(copy, &ok);
|
||||||
if (!ok && copy.contains(locale.groupSeparator()) && (max >= 1000 || min <= -1000)) {
|
if (!ok && (max >= 1000 || min <= -1000)) {
|
||||||
|
const QChar sep = locale.groupSeparator();
|
||||||
|
const QChar doubleSep[2] = {sep, sep};
|
||||||
|
if (copy.contains(sep) && !copy.contains(QString(doubleSep, 2))) {
|
||||||
QString copy2 = copy;
|
QString copy2 = copy;
|
||||||
copy2.remove(locale.groupSeparator());
|
copy2.remove(locale.groupSeparator());
|
||||||
num = locale.toInt(copy2, &ok);
|
num = locale.toInt(copy2, &ok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num;
|
QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num;
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
state = QValidator::Invalid;
|
state = QValidator::Invalid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user