Tolerate spaces at start and end of a POSIX zone descriptor
It's easy to do and makes an unremarkable user error harmless. In the process, add a comment to make QTBUG-112006 visible in the code. Pick-to: 6.9 6.8 6.5 Fixes: QTBUG-135109 Change-Id: I6b9cb431bf5b005fc0f9cdbb5cf30c90fa1154c4 Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This commit is contained in:
parent
cdcaaaeee3
commit
f682406162
@ -514,7 +514,7 @@ static inline bool asciiIsLetter(char ch)
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct PosixZone
|
struct PosixZone // TODO: QTBUG-112006 - make this cross-platform.
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
InvalidOffset = INT_MIN,
|
InvalidOffset = INT_MIN,
|
||||||
@ -600,7 +600,7 @@ static auto validatePosixRule(const QByteArray &posixRule, bool requireOffset =
|
|||||||
// See also calculatePosixTransition()'s reference.
|
// See also calculatePosixTransition()'s reference.
|
||||||
const auto parts = posixRule.split(',');
|
const auto parts = posixRule.split(',');
|
||||||
const struct { bool isValid, hasDst; } fail{false, false}, good{true, parts.size() > 1};
|
const struct { bool isValid, hasDst; } fail{false, false}, good{true, parts.size() > 1};
|
||||||
const QByteArray &zoneinfo = parts.at(0);
|
const QByteArray &zoneinfo = parts.at(0).trimmed();
|
||||||
if (zoneinfo.isEmpty())
|
if (zoneinfo.isEmpty())
|
||||||
return fail;
|
return fail;
|
||||||
|
|
||||||
@ -656,7 +656,7 @@ static QList<QTimeZonePrivate::Data> calculatePosixTransitions(const QByteArray
|
|||||||
|
|
||||||
PosixZone stdZone, dstZone;
|
PosixZone stdZone, dstZone;
|
||||||
{
|
{
|
||||||
const QByteArray &zoneinfo = parts.at(0);
|
const QByteArray &zoneinfo = parts.at(0).trimmed();
|
||||||
const char *begin = zoneinfo.constBegin();
|
const char *begin = zoneinfo.constBegin();
|
||||||
|
|
||||||
stdZone = PosixZone::parse(begin, zoneinfo.constEnd());
|
stdZone = PosixZone::parse(begin, zoneinfo.constEnd());
|
||||||
|
@ -1468,6 +1468,11 @@ void tst_QTimeZone::tzTest()
|
|||||||
QVERIFY(tzposix.isValid());
|
QVERIFY(tzposix.isValid());
|
||||||
QVERIFY(tzposix.hasDaylightTime());
|
QVERIFY(tzposix.hasDaylightTime());
|
||||||
|
|
||||||
|
// Cope with stray space at start of value (QTBUG-135109):
|
||||||
|
QTimeZone syd(" AEST-10AEDT,M10.1.0,M4.1.0/3");
|
||||||
|
QVERIFY(syd.isValid());
|
||||||
|
QVERIFY(syd.hasDaylightTime());
|
||||||
|
|
||||||
// RHEL has been seen with this as Africa/Casablanca's POSIX rule:
|
// RHEL has been seen with this as Africa/Casablanca's POSIX rule:
|
||||||
QTzTimeZonePrivate permaDst("<+00>0<+01>,0/0,J365/25");
|
QTzTimeZonePrivate permaDst("<+00>0<+01>,0/0,J365/25");
|
||||||
const QTimeZone utcP1("UTC+01:00"); // Should always have same offset as permaDst
|
const QTimeZone utcP1("UTC+01:00"); // Should always have same offset as permaDst
|
||||||
|
Loading…
x
Reference in New Issue
Block a user