From d12ba111e03fa4e6d76a66a029f5dbe6265b1ea9 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Tue, 10 Jan 2023 15:15:49 +0000 Subject: [PATCH] Fixed GH-10218: DateTimeZone fails to parse time zones that contain the "+" character --- NEWS | 2 ++ ext/date/lib/parse_date.c | 4 ++-- ext/date/lib/parse_date.re | 2 +- ext/date/tests/gh10218.phpt | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 ext/date/tests/gh10218.phpt diff --git a/NEWS b/NEWS index ad29b8f6118..0f8bbc31001 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,8 @@ PHP NEWS - Date: . Fixed bug GH-9891 (DateTime modify with unixtimestamp (@) must work like setTimestamp). (Derick) + . Fixed bug GH-10218 (DateTimeZone fails to parse time zones that contain the + "+" character). (Derick) - FPM: . Fixed bug GH-9981 (FPM does not reset fastcgi.error_header). diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index 99ec21baf56..78feb742081 100644 --- a/ext/date/lib/parse_date.c +++ b/ext/date/lib/parse_date.c @@ -1,4 +1,4 @@ -/* Generated by re2c 0.15.3 on Thu Dec 1 10:57:42 2022 */ +/* Generated by re2c 0.15.3 on Tue Jan 10 15:14:08 2023 */ #line 1 "ext/date/lib/parse_date.re" /* * The MIT License (MIT) @@ -761,7 +761,7 @@ static timelib_long timelib_lookup_abbr(const char **ptr, int *dst, char **tz_ab (**ptr >= 'A' && **ptr <= 'Z') || (**ptr >= 'a' && **ptr <= 'z') || (**ptr >= '0' && **ptr <= '9') || - **ptr == '/' || **ptr == '_' || **ptr == '-' + **ptr == '/' || **ptr == '_' || **ptr == '-' || **ptr == '+' ) { ++*ptr; } diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re index 923091ea89f..f0db34d302b 100644 --- a/ext/date/lib/parse_date.re +++ b/ext/date/lib/parse_date.re @@ -759,7 +759,7 @@ static timelib_long timelib_lookup_abbr(const char **ptr, int *dst, char **tz_ab (**ptr >= 'A' && **ptr <= 'Z') || (**ptr >= 'a' && **ptr <= 'z') || (**ptr >= '0' && **ptr <= '9') || - **ptr == '/' || **ptr == '_' || **ptr == '-' + **ptr == '/' || **ptr == '_' || **ptr == '-' || **ptr == '+' ) { ++*ptr; } diff --git a/ext/date/tests/gh10218.phpt b/ext/date/tests/gh10218.phpt new file mode 100644 index 00000000000..ff1b493ce7f --- /dev/null +++ b/ext/date/tests/gh10218.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug GH-10218 (DateTimeZone fails to parse time zones that contain the "+" character) +--FILE-- + +--EXPECTF-- +object(DateTime)#%d (%d) { + ["date"]=> + string(%d) "%s" + ["timezone_type"]=> + int(3) + ["timezone"]=> + string(9) "Etc/GMT+1" +}