Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions ext/date/lib/parse_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,20 +663,21 @@ static timelib_long timelib_get_month(const char **ptr)

static void timelib_eat_spaces(const char **ptr)
{
do {
/* Repetition is safe because it will fail as soon as a '\0' is encountered. */
again: {
if (**ptr == ' ' || **ptr == '\t') {
++*ptr;
continue;
goto again;
}
if ((*ptr)[0] == '\xe2' && (*ptr)[1] == '\x80' && (*ptr)[2] == '\xaf') { // NNBSP
*ptr += 3;
continue;
goto again;
}
if ((*ptr)[0] == '\xc2' && (*ptr)[1] == '\xa0') { // NBSP
*ptr += 2;
continue;
goto again;
}
} while (false);
}
}

static void timelib_eat_until_separator(const char **ptr)
Expand Down
11 changes: 6 additions & 5 deletions ext/date/lib/parse_date.re
Original file line number Diff line number Diff line change
Expand Up @@ -661,20 +661,21 @@ static timelib_long timelib_get_month(const char **ptr)

static void timelib_eat_spaces(const char **ptr)
{
do {
/* Repetition is safe because it will fail as soon as a '\0' is encountered. */
again: {
if (**ptr == ' ' || **ptr == '\t') {
++*ptr;
continue;
goto again;
}
if ((*ptr)[0] == '\xe2' && (*ptr)[1] == '\x80' && (*ptr)[2] == '\xaf') { // NNBSP
*ptr += 3;
continue;
goto again;
}
if ((*ptr)[0] == '\xc2' && (*ptr)[1] == '\xa0') { // NBSP
*ptr += 2;
continue;
goto again;
}
} while (false);
}
}

static void timelib_eat_until_separator(const char **ptr)
Expand Down
16 changes: 16 additions & 0 deletions ext/date/tests/gh11854.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
GH-11854 (8.2.9 DateTime:createFromFormat stopped parsing datetime with containing extra space.)
--FILE--
<?php
$dateTime = \DateTime::createFromFormat("D M d H:i:s Y", "Wed Aug 2 08:37:50 2023");
var_dump($dateTime);
?>
--EXPECT--
object(DateTime)#1 (3) {
["date"]=>
string(26) "2023-08-02 08:37:50.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}