Bartosz Dziewoński has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316737

Change subject: JpegMetadataExtractor: Don't fail when garbage bytes are 
present between JPEG sections
......................................................................

JpegMetadataExtractor: Don't fail when garbage bytes are present between JPEG 
sections

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.

Bug: T148606
Change-Id: I98f2609644bcd8bfd7c1679afc6e7af83e228685
---
M includes/media/JpegMetadataExtractor.php
1 file changed, 4 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/37/316737/1

diff --git a/includes/media/JpegMetadataExtractor.php 
b/includes/media/JpegMetadataExtractor.php
index 9ad4097..67c957a 100644
--- a/includes/media/JpegMetadataExtractor.php
+++ b/includes/media/JpegMetadataExtractor.php
@@ -82,9 +82,10 @@
                                // 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 );

-- 
To view, visit https://gerrit.wikimedia.org/r/316737
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I98f2609644bcd8bfd7c1679afc6e7af83e228685
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to