summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2018-11-05 13:15:13 +0100
committerLiang Qi <liang.qi@qt.io>2018-11-09 21:43:00 +0000
commit1cc30fe77d04f745263525e0d4d5e7796ecf792c (patch)
treeec2b6ff846406974c07caebcc0d7116ebb127b1e
parent60f53298544d52d36eb44247bab5d86c8e093117 (diff)
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>
-rw-r--r--src/widgets/widgets/qspinbox.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp
index dcf3906dd7..7624b1ed3c 100644
--- a/src/widgets/widgets/qspinbox.cpp
+++ b/src/widgets/widgets/qspinbox.cpp
@@ -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;