Skip to content

Commit ad261a2

Browse files
Merge pull request #11967 from havocbcn/jpg-rgb
Do not transform jpeg RGB components
2 parents 96ad60f + 802aa14 commit ad261a2

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

src/core/jpg.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,10 @@ var JpegImage = (function JpegImageClosure() {
991991
var components = [],
992992
component;
993993
for (i = 0; i < selectorsCount; i++) {
994-
var componentIndex = frame.componentIds[data[offset++]];
994+
const index = data[offset++];
995+
var componentIndex = frame.componentIds[index];
995996
component = frame.components[componentIndex];
997+
component.index = index;
996998
var tableSpec = data[offset++];
997999
component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
9981000
component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
@@ -1088,6 +1090,7 @@ var JpegImage = (function JpegImageClosure() {
10881090
}
10891091

10901092
this.components.push({
1093+
index: component.index,
10911094
output: buildComponentData(frame, component),
10921095
scaleX: component.h / frame.maxH,
10931096
scaleY: component.v / frame.maxV,
@@ -1183,6 +1186,14 @@ var JpegImage = (function JpegImageClosure() {
11831186
// dictionary has a 'ColorTransform' entry, explicitly set to `0`,
11841187
// then the colours should *not* be transformed.
11851188
return false;
1189+
} else if (
1190+
this.components[0].index === /* "R" = */ 0x52 &&
1191+
this.components[1].index === /* "G" = */ 0x47 &&
1192+
this.components[2].index === /* "B" = */ 0x42
1193+
) {
1194+
// If the three components are indexed as RGB in ASCII
1195+
// then the colours should *not* be transformed.
1196+
return false;
11861197
}
11871198
return true;
11881199
}

test/pdfs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
!issue1055r.pdf
148148
!issue11713.pdf
149149
!issue1293r.pdf
150+
!issue11931.pdf
150151
!issue1655r.pdf
151152
!issue6541.pdf
152153
!issue2948.pdf

test/pdfs/issue11931.pdf

6.51 KB
Binary file not shown.

test/test_manifest.json

+6
Original file line numberDiff line numberDiff line change
@@ -4367,6 +4367,12 @@
43674367
"type": "eq",
43684368
"forms": true
43694369
},
4370+
{ "id": "issue11931",
4371+
"file": "pdfs/issue11931.pdf",
4372+
"md5": "9ea233037992e1f10280420a49e72845",
4373+
"rounds": 1,
4374+
"type": "eq"
4375+
},
43704376
{ "id": "annotation-button-widget-annotations",
43714377
"file": "pdfs/annotation-button-widget.pdf",
43724378
"md5": "5cf23adfff84256d9cfe261bea96dade",

0 commit comments

Comments
 (0)