mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 14:48:08 +02:00
Merge pull request #19356 from Snuffleupagus/bug-1942064-2
Replace the EXIF-block with dummy data to prevent JPEG images being rotated (bug 1942064)
This commit is contained in:
commit
850e605e36
4 changed files with 31 additions and 0 deletions
|
@ -817,6 +817,29 @@ class JpegImage {
|
|||
|
||||
markerLoop: while (fileMarker !== /* EOI (End of Image) = */ 0xffd9) {
|
||||
switch (fileMarker) {
|
||||
case 0xffe1: // APP1 - Exif
|
||||
// TODO: Remove this once https://github.com/w3c/webcodecs/issues/870
|
||||
// is fixed.
|
||||
const { appData, newOffset } = readDataBlock(data, offset);
|
||||
offset = newOffset;
|
||||
|
||||
// 'Exif\x00\x00'
|
||||
if (
|
||||
appData[0] === 0x45 &&
|
||||
appData[1] === 0x78 &&
|
||||
appData[2] === 0x69 &&
|
||||
appData[3] === 0x66 &&
|
||||
appData[4] === 0 &&
|
||||
appData[5] === 0
|
||||
) {
|
||||
// Replace the entire EXIF-block with dummy data, to ensure that a
|
||||
// non-default EXIF orientation won't cause the image to be rotated
|
||||
// when using `ImageDecoder` (fixes bug1942064.pdf).
|
||||
appData.fill(0x00, 6);
|
||||
}
|
||||
fileMarker = readUint16(data, offset);
|
||||
offset += 2;
|
||||
continue;
|
||||
case 0xffc0: // SOF0 (Start of Frame, Baseline DCT)
|
||||
case 0xffc1: // SOF1 (Start of Frame, Extended DCT)
|
||||
case 0xffc2: // SOF2 (Start of Frame, Progressive DCT)
|
||||
|
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -503,6 +503,7 @@
|
|||
!annotation-line-without-appearance.pdf
|
||||
!bug1669099.pdf
|
||||
!annotation-square-circle.pdf
|
||||
!bug1942064.pdf
|
||||
!annotation-square-circle-without-appearance.pdf
|
||||
!annotation-stamp.pdf
|
||||
!issue14048.pdf
|
||||
|
|
BIN
test/pdfs/bug1942064.pdf
Normal file
BIN
test/pdfs/bug1942064.pdf
Normal file
Binary file not shown.
|
@ -8997,6 +8997,13 @@
|
|||
"link": true,
|
||||
"type": "other"
|
||||
},
|
||||
{
|
||||
"id": "bug1942064",
|
||||
"file": "pdfs/bug1942064.pdf",
|
||||
"md5": "d50b5ebb8cab1211609d16faa54ec47d",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{
|
||||
"id": "issue16221-text",
|
||||
"file": "pdfs/issue16221.pdf",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue