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
// 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 );