X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fmedia%2FJpegMetadataExtractor.php;h=211845cc8f6f663a290a4e159ec0881c4b2e58aa;hp=9ad40977bcb74d38abb4f6cd2a0ef5da6073dc16;hb=64b83bdb3afd0ee4f8fc1893a865409c198e601e;hpb=7c6d2a0fa28746b49d79345b609d9c7605ed4d63 diff --git a/includes/media/JpegMetadataExtractor.php b/includes/media/JpegMetadataExtractor.php index 9ad40977bc..211845cc8f 100644 --- a/includes/media/JpegMetadataExtractor.php +++ b/includes/media/JpegMetadataExtractor.php @@ -82,9 +82,10 @@ class JpegMetadataExtractor { // this is just a sanity check throw new MWException( 'Too many jpeg segments. Aborting' ); } - if ( $buffer !== "\xFF" ) { - throw new MWException( "Error reading jpeg file marker. " . - "Expected 0xFF but got " . bin2hex( $buffer ) ); + while ( $buffer !== "\xFF" ) { + // In theory JPEG files are not allowed to contain anything between the sections, + // but in practice they sometimes do. It's customary to ignore the garbage data. + $buffer = fread( $fh, 1 ); } $buffer = fread( $fh, 1 ); @@ -93,7 +94,6 @@ class JpegMetadataExtractor { $buffer = fread( $fh, 1 ); } if ( $buffer === "\xFE" ) { - // COM section -- file comment // First see if valid utf-8, // if not try to convert it to windows-1252.