Catch invalidly-placed exponents on conversion to C locale
Although the number-parsing code to which the C-locale form is later passed was already rejecting such malformed texts, it's better to catch it earlier and to make the check overt in that parsing. Added some tests cases that would fail if this wasn't checked; but they do pass already in the parent. Pick-to: 6.8 6.5 Change-Id: I5ef9e483317ce4dc519ddc7c4c016dcad5cb22c4 Reviewed-by: Dennis Oberst <dennis.oberst@qt.io> (cherry picked from commit f1d48552e4dfbcdbfd060dd8dd924ae433e7f4c6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d94d5bcd61
commit
ae31e6e6ac
@ -4540,7 +4540,7 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o
|
||||
return false;
|
||||
stage = Fraction;
|
||||
} else if (out == 'e') {
|
||||
if (stage == Name)
|
||||
if (wantDigits || stage == Name || stage > Fraction)
|
||||
return false;
|
||||
|
||||
if (stage < Fraction) {
|
||||
|
@ -909,6 +909,9 @@ void tst_QLocale::toReal_data()
|
||||
QTest::newRow("C 1.") << QString("C") << QString("1.") << true << 1.0;
|
||||
QTest::newRow("C 1.E10") << QString("C") << QString("1.E10") << true << 1.0e10;
|
||||
QTest::newRow("C 1e+10") << QString("C") << QString("1e+10") << true << 1.0e+10;
|
||||
QTest::newRow("C e+10") << QString("C") << QString("e+10") << false << 0.0;
|
||||
QTest::newRow("C .e+10") << QString("C") << QString(".e+10") << false << 0.0;
|
||||
QTest::newRow("C 1e+2e+10") << QString("C") << QString("1e+2e+10") << false << 0.0;
|
||||
|
||||
QTest::newRow("de_DE 1.") << QString("de_DE") << QString("1.") << false << 0.0;
|
||||
QTest::newRow("de_DE 1.2") << QString("de_DE") << QString("1.2") << false << 0.0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user