Allow longer time-zone components on Android
Android uses its own time-zone naming, which includes a zone called "Canada/East-Saskatchewan", whose second component is 17 characters long. This violates a rule in the IANA naming scheme for zones, that limits components to 14 characters each. So tweak the isValidId() check to allow Android its long names. Android has added Outer Mongolian time-zones, which are as borked as many others in 1970, so blacklist those transitionEachZone() tests. Fixes: QTBUG-69128 Change-Id: I46f674f095431335b16900860d83b624257ae3bb Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
This commit is contained in:
parent
103d307f2e
commit
ad11cab484
@ -632,7 +632,13 @@ bool QTimeZonePrivate::isValidId(const QByteArray &ianaId)
|
||||
|
||||
// Somewhat slack hand-rolled version:
|
||||
const int MinSectionLength = 1;
|
||||
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
|
||||
// Android has its own naming of zones.
|
||||
// "Canada/East-Saskatchewan" has a 17-character second component.
|
||||
const int MaxSectionLength = 17;
|
||||
#else
|
||||
const int MaxSectionLength = 14;
|
||||
#endif
|
||||
int sectionLength = 0;
|
||||
for (const char *it = ianaId.begin(), * const end = ianaId.end(); it != end; ++it, ++sectionLength) {
|
||||
const char ch = *it;
|
||||
|
@ -2,10 +2,6 @@
|
||||
[dataStreamTest]
|
||||
android
|
||||
|
||||
# QTBUG-69128
|
||||
[isTimeZoneIdAvailable]
|
||||
android
|
||||
|
||||
# QTBUG-69129
|
||||
[specificTransition]
|
||||
android
|
||||
@ -75,10 +71,14 @@ android
|
||||
android
|
||||
[transitionEachZone:Asia/Chita@1970]
|
||||
android
|
||||
[transitionEachZone:Asia/Choibalsan@1970]
|
||||
android
|
||||
[transitionEachZone:Asia/Dushanbe@1970]
|
||||
android
|
||||
[transitionEachZone:Asia/Ho_Chi_Minh@1970]
|
||||
android
|
||||
[transitionEachZone:Asia/Hovd@1970]
|
||||
android
|
||||
[transitionEachZone:Asia/Kathmandu@1970]
|
||||
android
|
||||
[transitionEachZone:Asia/Katmandu@1970]
|
||||
@ -109,6 +109,10 @@ android
|
||||
android
|
||||
[transitionEachZone:Asia/Thimphu@1970]
|
||||
android
|
||||
[transitionEachZone:Asia/Ulaanbaatar@1970]
|
||||
android
|
||||
[transitionEachZone:Asia/Ulan_Bator@1970]
|
||||
android
|
||||
[transitionEachZone:Asia/Ust-Nera@1970]
|
||||
android
|
||||
[transitionEachZone:Atlantic/Cape_Verde@1970]
|
||||
|
@ -706,6 +706,7 @@ void tst_QTimeZone::isValidId_data()
|
||||
// a-z, A-Z, 0-9, '.', '-', '_' are valid chars
|
||||
// Can't start with '-'
|
||||
// Parts separated by '/', each part min 1 and max of 14 chars
|
||||
// (Android has parts with lengths up to 17, so tolerates this as a special case.)
|
||||
#define TESTSET(name, section, valid) \
|
||||
QTest::newRow(name " front") << QByteArray(section "/xyz/xyz") << valid; \
|
||||
QTest::newRow(name " middle") << QByteArray("xyz/" section "/xyz") << valid; \
|
||||
@ -713,8 +714,13 @@ void tst_QTimeZone::isValidId_data()
|
||||
|
||||
TESTSET("empty", "", false);
|
||||
TESTSET("minimal", "m", true);
|
||||
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
|
||||
TESTSET("maximal", "East-Saskatchewan", true); // Android actually uses this
|
||||
TESTSET("too long", "North-Saskatchewan", false); // ... but thankfully not this.
|
||||
#else
|
||||
TESTSET("maximal", "12345678901234", true);
|
||||
TESTSET("too long", "123456789012345", false);
|
||||
#endif
|
||||
|
||||
TESTSET("bad hyphen", "-hyphen", false);
|
||||
TESTSET("good hyphen", "hy-phen", true);
|
||||
@ -759,8 +765,13 @@ void tst_QTimeZone::isValidId_data()
|
||||
QTest::newRow("a,z alone") << QByteArray("a,z") << false;
|
||||
QTest::newRow("/z alone") << QByteArray("/z") << false;
|
||||
QTest::newRow("-z alone") << QByteArray("-z") << false;
|
||||
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
|
||||
QTest::newRow("long alone") << QByteArray("12345678901234567") << true;
|
||||
QTest::newRow("over-long alone") << QByteArray("123456789012345678") << false;
|
||||
#else
|
||||
QTest::newRow("long alone") << QByteArray("12345678901234") << true;
|
||||
QTest::newRow("over-long alone") << QByteArray("123456789012345") << false;
|
||||
#endif
|
||||
|
||||
#else
|
||||
QSKIP("This test requires a Qt -developer-build.");
|
||||
|
Loading…
Reference in New Issue
Block a user