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.9 6.8 6.5 Change-Id: I5ef9e483317ce4dc519ddc7c4c016dcad5cb22c4 Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This commit is contained in:
parent
d1879c3a39
commit
f1d48552e4
@ -4659,7 +4659,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) {
|
||||
|
@ -913,6 +913,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