From b1bee7036772a64f6d2c663d6ea8ee456db07db8 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Thu, 3 Aug 2023 09:17:14 +0100 Subject: [PATCH] Fixed PHP GH-11854: DateTime:createFromFormat stopped parsing datetime with extra space --- parse_date.re | 3 ++- tests/c/parse_date_from_format_test.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/parse_date.re b/parse_date.re index 43444e3..f634de1 100644 --- a/parse_date.re +++ b/parse_date.re @@ -674,7 +674,8 @@ static void timelib_eat_spaces(const char **ptr) *ptr += 2; continue; } - } while (false); + break; + } while (true); } static void timelib_eat_until_separator(const char **ptr) diff --git a/tests/c/parse_date_from_format_test.cpp b/tests/c/parse_date_from_format_test.cpp index e112013..e6e1a77 100644 --- a/tests/c/parse_date_from_format_test.cpp +++ b/tests/c/parse_date_from_format_test.cpp @@ -3308,3 +3308,16 @@ TEST(parse_date_from_format, bug_gh9700) test_parse("2022-02-18T00:00:00+01:00[Europe/Berlin]", "Y-m-d\\TH:i:sP[e]"); STRCMP_EQUAL("Europe/Berlin", t->tz_info->name); } + +TEST(parse_date_from_format, bug_gh11854) +{ + test_parse("Wed Aug 2 08:37:50 2023", "D M d H:i:s Y"); + LONGS_EQUAL(0, errors->error_count); + LONGS_EQUAL(0, errors->warning_count); + LONGS_EQUAL(2023, t->y); + LONGS_EQUAL( 8, t->m); + LONGS_EQUAL( 2, t->d); + LONGS_EQUAL( 8, t->h); + LONGS_EQUAL(37, t->i); + LONGS_EQUAL(50, t->s); +}