From 16c96837182056a1a755e420289dce8a57341c6c Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 28 Apr 2021 15:25:19 +0200 Subject: [PATCH] Revert early return from QTimeZone on invalid ID MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ec8808c3020abbc436f1a2d90fecf3245fd6417b but retains its test, as the problem it fixed is now solved by having the TZ backend validate the ID it's passed, so that it now only accepts valid POSIX zone-descriptions and valid IANA IDs. The former were being excluded by this check. Amended a POSIX test to fail with the check in place; it passes now. Change-Id: I0d5e8c6e0a315ac2509f3d23bebb52aede8f79d0 Reviewed-by: Thiago Macieira Reviewed-by: Robert Löhning --- src/corelib/time/qtimezone.cpp | 3 --- tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/corelib/time/qtimezone.cpp b/src/corelib/time/qtimezone.cpp index 8baa4cb592d..74c09fb9278 100644 --- a/src/corelib/time/qtimezone.cpp +++ b/src/corelib/time/qtimezone.cpp @@ -334,9 +334,6 @@ QTimeZone::QTimeZone() noexcept QTimeZone::QTimeZone(const QByteArray &ianaId) { - // If invalid (other than empty), reject immediately: - if (!ianaId.isEmpty() && !QTimeZonePrivate::isValidId(ianaId)) - return; // Try and see if it's a CLDR UTC offset ID - just as quick by creating as // by looking up. d = new QUtcTimeZonePrivate(ianaId); diff --git a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp index f1c29342cf0..445cf89755f 100644 --- a/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/time/qtimezone/tst_qtimezone.cpp @@ -1138,7 +1138,7 @@ void tst_QTimeZone::tzTest() QVERIFY(tzp.isValid()); // Test POSIX-format value for $TZ: - QTzTimeZonePrivate tzposix("MET-1METDST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"); + QTimeZone tzposix("MET-1METDST-2,M3.5.0/02:00:00,M10.5.0/03:00:00"); QVERIFY(tzposix.isValid()); QVERIFY(tzposix.hasDaylightTime());