Commit 90a271f0f4a for php

commit 90a271f0f4ae6c6f39047e04a06b79ae2b411864
Author: Alexander Danilov <10532067+adapik@users.noreply.github.com>
Date:   Fri Oct 16 12:22:10 2026 +0300

    date: Validate ISO 8601 duration strings for null bytes early (#24357)

diff --git a/ext/date/tests/time/duration/methods/fromIso8601DurationString.phpt b/ext/date/tests/time/duration/methods/fromIso8601DurationString.phpt
index 109a1dd1307..aee7ce5df5b 100644
--- a/ext/date/tests/time/duration/methods/fromIso8601DurationString.phpt
+++ b/ext/date/tests/time/duration/methods/fromIso8601DurationString.phpt
@@ -34,10 +34,14 @@
     'P1DT0S',
     '2000-01-01T00:00:00Z',
     '2000-01-01T00:00:00Z/PT1H',
+
+    "PT5S\0garbage",
+    "PT5S\0",
+    "\0PT5S",
 ];

 foreach ($specifications as $specification) {
-    printf("%-25s: ", $specification);
+    printf("%-25s: ", addcslashes($specification, "\0"));

     try {
         echo f(Time\Duration::fromIso8601DurationString($specification)), PHP_EOL;
@@ -72,3 +76,6 @@
 P1DT0S                   : Time\TimeException: The ISO 8601 duration string may only contain the time (T) aspect
 2000-01-01T00:00:00Z     : Time\TimeException: The ISO 8601 duration string is missing the period (P) aspect
 2000-01-01T00:00:00Z/PT1H: Time\TimeException: The ISO 8601 duration string may only contain the period (P) aspect
+PT5S\000garbage          : Time\TimeException: The ISO 8601 duration string could not be parsed
+PT5S\000                 : Time\TimeException: The ISO 8601 duration string could not be parsed
+\000PT5S                 : Time\TimeException: The ISO 8601 duration string could not be parsed
diff --git a/ext/date/time_duration.c b/ext/date/time_duration.c
index 8565f3e8c5f..1365bd627af 100644
--- a/ext/date/time_duration.c
+++ b/ext/date/time_duration.c
@@ -326,6 +326,11 @@ PHP_METHOD(Time_Duration, fromIso8601DurationString)
 		Z_PARAM_STR(specification);
 	ZEND_PARSE_PARAMETERS_END();

+	if (zend_str_has_nul_byte(specification)) {
+		throw_timelib_error(TIMELIB_ERROR_ISO8601_DURATION_PARSE_FAILURE);
+		RETURN_THROWS();
+	}
+
 	int error;
 	timelib_duration *d = timelib_duration_create_from_iso8601string(ZSTR_VAL(specification), &error);
 	if (error != TIMELIB_ERROR_NO_ERROR) {