@@ -445,19 +445,11 @@ static bool datetime_parse(const MCDateTimeLocale *p_locale, int4 p_century_cuto
445445 t_valid = true ;
446446 break ;
447447 }
448-
449- // FG-2013-09-10 [[ Bug 11162 ]]
450- // Trailing spaces after an accepted format specifier should be squashed
451- if (t_valid && !t_skip)
452- {
453- while (p_format[1 ] != ' \0 ' && isspace (p_format[1 ]))
454- p_format++;
455- while (t_input_length > 1 && isspace (t_input[1 ]))
456- t_input++, t_input_length--;
457- }
458448
459449 }
460- else if (*p_format != *t_input)
450+ // FG-2013-10-08 [[ Bugfix 11261 ]]
451+ // If there is an extra space in the format string, treat it as a match
452+ else if (*p_format != *t_input && !isspace (*p_format))
461453 {
462454 // Unrecognised padding is optional, so advance and skip
463455 if (t_loose_separators)
@@ -486,15 +478,25 @@ static bool datetime_parse(const MCDateTimeLocale *p_locale, int4 p_century_cuto
486478 {
487479 // FG-2013-09-10 [[ Bug 11162 ]]
488480 // One or more spaces in the format string should accept any number of input spaces
489- while (t_input_length > 0 && isspace (*t_input))
490- t_input += 1 , t_input_length -= 1 ;
491- while (*p_format != ' \0 ' && isspace (*p_format))
492- p_format++;
493-
494- if (t_input_length > 0 )
481+ // FG-2013-10-08 [[ Bug 11261 ]]
482+ // Over-incrementing of format pointer caused internet dates to parse incorrectly
483+ if (isspace (*p_format))
495484 {
496- t_input += 1 ;
497- t_input_length -= 1 ;
485+ while (t_input_length > 0 && isspace (*t_input))
486+ t_input += 1 , t_input_length -= 1 ;
487+
488+ // Format is incremented past the current char below so just
489+ // remove additional spaces here and leave one for it.
490+ while (p_format[1 ] != ' \0 ' && isspace (p_format[1 ]))
491+ p_format++;
492+ }
493+ else
494+ {
495+ if (t_input_length > 0 )
496+ {
497+ t_input += 1 ;
498+ t_input_length -= 1 ;
499+ }
498500 }
499501 t_valid = true ;
500502 }
0 commit comments