From 1cc30fe77d04f745263525e0d4d5e7796ecf792c Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Mon, 5 Nov 2018 13:15:13 +0100 Subject: 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 --- src/widgets/widgets/qspinbox.cpp | 12 ++++++++---- 1 file 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; -- cgit v1.2.3