You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: handle 0x00E1 / 0x00E0 segments from Pixel phones (jpeg-js#84)
* add unit test to reproduce jpeg-js#82
* Added new case to deal with e0 and e1 unused byte markers
* Popular invalid filemarkers now treated as exceptions
Co-authored-by: Hisham Al-Shurafa <[email protected]>
Co-authored-by: Anthony Tang <[email protected]>
Copy file name to clipboardExpand all lines: lib/decoder.js
+14-1Lines changed: 14 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -623,6 +623,7 @@ var JpegImage = (function jpegImage() {
623
623
varquantizationTables=[],frames=[];
624
624
varhuffmanTablesAC=[],huffmanTablesDC=[];
625
625
varfileMarker=readUint16();
626
+
varmalformedDataOffset=-1;
626
627
this.comments=[];
627
628
if(fileMarker!=0xFFD8){// SOI (Start of Image)
628
629
thrownewError("SOI not found");
@@ -813,7 +814,6 @@ var JpegImage = (function jpegImage() {
813
814
offset--;
814
815
}
815
816
break;
816
-
817
817
default:
818
818
if(data[offset-3]==0xFF&&
819
819
data[offset-2]>=0xC0&&data[offset-2]<=0xFE){
@@ -822,6 +822,19 @@ var JpegImage = (function jpegImage() {
822
822
offset-=3;
823
823
break;
824
824
}
825
+
elseif(fileMarker===0xE0||fileMarker==0xE1){
826
+
// Recover from malformed APP1 markers popular in some phone models.
827
+
// See https://github.com/eugeneware/jpeg-js/issues/82
828
+
if(malformedDataOffset!==-1){
829
+
thrownewError(`first unknown JPEG marker at offset ${malformedDataOffset.toString(16)}, second unknown JPEG marker ${fileMarker.toString(16)} at offset ${(offset-1).toString(16)}`);
0 commit comments