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:
Eirik Aavitsland 2018-11-05 13:15:13 +01:00 committed by Liang Qi
parent 60f5329854
commit 1cc30fe77d

View File

@ -1134,10 +1134,14 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos,
num = copy.toInt(&ok, displayIntegerBase);
} else {
num = locale.toInt(copy, &ok);
if (!ok && copy.contains(locale.groupSeparator()) && (max >= 1000 || min <= -1000)) {
QString copy2 = copy;
copy2.remove(locale.groupSeparator());
num = locale.toInt(copy2, &ok);
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;
copy2.remove(locale.groupSeparator());
num = locale.toInt(copy2, &ok);
}
}
}
QSBDEBUG() << __FILE__ << __LINE__<< "num is set to" << num;