Skip to content

Commit

Permalink
Fixed GH-10218: DateTimeZone fails to parse time zones that contain t…
Browse files Browse the repository at this point in the history
…he "+" character
  • Loading branch information
derickr committed Jan 10, 2023
1 parent a9e7b90 commit d12ba11
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 2 additions & 2 deletions ext/date/lib/parse_date.c
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion ext/date/lib/parse_date.re
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 15 additions & 0 deletions ext/date/tests/gh10218.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
Bug GH-10218 (DateTimeZone fails to parse time zones that contain the "+" character)
--FILE--
<?php
var_dump(new DateTime('now', new DateTimeZone('Etc/GMT+1')));
?>
--EXPECTF--
object(DateTime)#%d (%d) {
["date"]=>
string(%d) "%s"
["timezone_type"]=>
int(3)
["timezone"]=>
string(9) "Etc/GMT+1"
}

0 comments on commit d12ba11

Please sign in to comment.