Improve detection of binary/ASCII eexec encrypted Type1 font programs in Type1Parser (issue 11740)

The PDF document, in the referenced issue, actually contains ASCII-encoded Type1 data which we currently *incorrectly* identify as binary.

According to the specification, see https://www-cdf.fnal.gov/offline/PostScript/T1_SPEC.PDF#[{%22num%22%3A203%2C%22gen%22%3A0}%2C{%22name%22%3A%22XYZ%22}%2C87%2C452%2Cnull], the current checks are insufficient to decide between binary/ASCII encoded Type1 font programs.
This commit is contained in:
Jonas Jenwald 2020-03-25 13:57:51 +01:00
parent 0400109b87
commit 6a8c591301

View File

@ -457,10 +457,14 @@ var Type1Parser = (function Type1ParserClosure() {
if (encrypted) {
var data = stream.getBytes();
var isBinary = !(
isHexDigit(data[0]) &&
(isHexDigit(data[0]) || isWhiteSpace(data[0])) &&
isHexDigit(data[1]) &&
isHexDigit(data[2]) &&
isHexDigit(data[3])
isHexDigit(data[3]) &&
isHexDigit(data[4]) &&
isHexDigit(data[5]) &&
isHexDigit(data[6]) &&
isHexDigit(data[7])
);
stream = new Stream(
isBinary