Skip to content

Commit

Permalink
Fix copying on supplementary plane characters
Browse files Browse the repository at this point in the history
pdf.js had a problem when copying characters on supplementary planes
(0xPPXXXX where PP is nonzero).  This is because certain methods of
PartialEvaluator use classic String.fromCharCode instead of ES6's
String.fromCodePoint.

Despite the fact that readToUnicode method *tried* to parse out-of-UCS2
code points by parsing UTF-16BE, it was inadequate because
String.fromCharCode only supports UCS-2 range of Unicode.
  • Loading branch information
a4lg committed Feb 10, 2019
1 parent 2b6e636 commit 96ba6af
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
continue;
}
}
toUnicode[charcode] = String.fromCharCode(code);
toUnicode[charcode] = String.fromCodePoint(code);
}
continue;
}
Expand Down Expand Up @@ -2179,7 +2179,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var w2 = (token.charCodeAt(k) << 8) | token.charCodeAt(k + 1);
str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
}
map[charCode] = String.fromCharCode.apply(String, str);
map[charCode] = String.fromCodePoint.apply(String, str);
});
return new ToUnicodeMap(map);
});
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
!issue9940.pdf
!issue10388_reduced.pdf
!issue10438_reduced.pdf
!issue10529.pdf
!bad-PageLabels.pdf
!decodeACSuccessive.pdf
!filled-background.pdf
Expand Down
Binary file added test/pdfs/issue10529.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,13 @@
"type": "eq",
"nativeImageDecoderSupport": "none"
},
{ "id": "issue10529",
"file": "pdfs/issue10529.pdf",
"md5": "1a4d404a137c610ff0c747cbea3b8666",
"rounds": 1,
"link": false,
"type": "text"
},
{ "id": "issue6071",
"file": "pdfs/issue6071.pdf",
"md5": "2e08526d8e7c9ba4269fc12ef488d3eb",
Expand Down

0 comments on commit 96ba6af

Please sign in to comment.