X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fmedia%2FJpegMetadataExtractor.php;h=0bd01cd6c94142b3fdaff2bab1987df4c1581185;hp=67c957adac13a75b448c54aed2779081456d24ea;hb=8624538de243da3779db5eb3362bedf78d2e2931;hpb=72b9240497311a2fa5f5b76d9e8bb953dc59853f diff --git a/includes/media/JpegMetadataExtractor.php b/includes/media/JpegMetadataExtractor.php index 67c957adac..0bd01cd6c9 100644 --- a/includes/media/JpegMetadataExtractor.php +++ b/includes/media/JpegMetadataExtractor.php @@ -82,7 +82,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 ); @@ -94,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. @@ -103,9 +102,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.