X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fmedia%2FJpegMetadataExtractor.php;h=8a26f606f978c292ece3d2b4789cfac3b7920355;hb=c1c3302286deb92f3eb81a39b5ee61f8c413f5ad;hp=211845cc8f6f663a290a4e159ec0881c4b2e58aa;hpb=237d3271fd313ebe09858a5c442a91216a7b61cf;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/media/JpegMetadataExtractor.php b/includes/media/JpegMetadataExtractor.php index 211845cc8f..8a26f606f9 100644 --- a/includes/media/JpegMetadataExtractor.php +++ b/includes/media/JpegMetadataExtractor.php @@ -21,6 +21,8 @@ * @ingroup Media */ +use Wikimedia\XMPReader\Reader as XMPReader; + /** * Class for reading jpegs and extracting metadata. * see also BitmapMetadataHandler. @@ -82,7 +84,7 @@ class JpegMetadataExtractor { // this is just a sanity check throw new MWException( 'Too many jpeg segments. Aborting' ); } - while ( $buffer !== "\xFF" ) { + while ( $buffer !== "\xFF" && !feof( $fh ) ) { // 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 ); @@ -102,9 +104,9 @@ class JpegMetadataExtractor { // turns $com to valid utf-8. // thus if no change, its utf-8, otherwise its something else. if ( $com !== $oldCom ) { - MediaWiki\suppressWarnings(); + Wikimedia\suppressWarnings(); $com = $oldCom = iconv( 'windows-1252', 'UTF-8//IGNORE', $oldCom ); - MediaWiki\restoreWarnings(); + Wikimedia\restoreWarnings(); } // Try it again, if its still not a valid string, then probably // binary junk or some really weird encoding, so don't extract. @@ -158,6 +160,8 @@ class JpegMetadataExtractor { if ( $size['int'] < 2 ) { throw new MWException( "invalid marker size in jpeg" ); } + // Note it's possible to seek beyond end of file if truncated. + // fseek doesn't report a failure in this case. fseek( $fh, $size['int'] - 2, SEEK_CUR ); } }