From d45daa49d8e6eb55962c747767c5d069e23a1c92 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 6 Sep 2012 12:10:57 -0700 Subject: [PATCH] try/catch for bug 40037 weird timestamps in exif Change-Id: I474bb796328baab6ca123d68c3ce7cf78fccfd3a --- includes/media/FormatMetadata.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/includes/media/FormatMetadata.php b/includes/media/FormatMetadata.php index 691440228e..843c1fa22d 100644 --- a/includes/media/FormatMetadata.php +++ b/includes/media/FormatMetadata.php @@ -104,10 +104,16 @@ class FormatMetadata { . ':' . str_pad( intval( $m[0] / $m[1] ), 2, '0', STR_PAD_LEFT ) . ':' . str_pad( intval( $s[0] / $s[1] ), 2, '0', STR_PAD_LEFT ); - $time = wfTimestamp( TS_MW, '1971:01:01 ' . $tags[$tag] ); - // the 1971:01:01 is just a placeholder, and not shown to user. - if ( $time && intval( $time ) > 0 ) { - $tags[$tag] = $wgLang->time( $time ); + try { + $time = wfTimestamp( TS_MW, '1971:01:01 ' . $tags[$tag] ); + // the 1971:01:01 is just a placeholder, and not shown to user. + if ( $time && intval( $time ) > 0 ) { + $tags[$tag] = $wgLang->time( $time ); + } + } catch ( TimestampException $e ) { + // This shouldn't happen, but we've seen bad formats + // such as 4-digit seconds in the wild. + // leave $tags[$tag] as-is } continue; } -- 2.20.1