File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -371,7 +371,7 @@ protected function checkRfc3339Time(string $rfcTime): bool
371371 return false ;
372372 }
373373
374- if ($ seconds === '60 ' && ( $ hours !== ' 23 ' || $ minutes !== ' 59 ' )) {
374+ if ($ seconds === '60 ' && ! $ this -> checkRfc3339TimeLeapSecond ( $ rfcTime )) {
375375 // Invalid leap second
376376 return false ;
377377 }
@@ -399,7 +399,7 @@ protected function checkRfc3339Time(string $rfcTime): bool
399399 $ normalizedMinutes = abs ((int ) $ minutes - (int ) $ offsetMinutes ) % 60 ;
400400 }
401401
402- if ($ seconds === '60 ' && ( $ normalizedHours !== 23 || $ normalizedMinutes !== 59 )) {
402+ if ($ seconds === '60 ' && ! $ this -> checkRfc3339TimeLeapSecond ( $ rfcTime )) {
403403 // Invalid leap second
404404 return false ;
405405 }
@@ -408,6 +408,23 @@ protected function checkRfc3339Time(string $rfcTime): bool
408408 return true ;
409409 }
410410
411+ protected function checkRfc3339TimeLeapSecond (string $ rfcTime ): bool
412+ {
413+ try {
414+ $ dateTime = (new \DateTime ($ rfcTime ));
415+ $ dateTime ->setTimezone (new \DateTimeZone ('UTC ' ));
416+ if ($ dateTime ->format ('His ' ) !== '000000 ' ) {
417+ // Invalid leap second
418+ return false ;
419+ }
420+ } catch (\Exception ) {
421+ // Invalid leap second
422+ return false ;
423+ }
424+
425+ return true ;
426+ }
427+
411428 protected function checkDuration (string $ duration ): bool
412429 {
413430 if (preg_match (static ::PATTERN_DURATION , $ duration ) !== 1 ) {
You can’t perform that action at this time.
0 commit comments