Fix arcfour initialization and encoding; png prediction fix
This commit is contained in:
parent
da30105b13
commit
63e74b53e9
14
pdf.js
14
pdf.js
@ -716,7 +716,7 @@ var PredictorStream = (function() {
|
|||||||
var rawBytes = this.stream.getBytes(rowBytes);
|
var rawBytes = this.stream.getBytes(rowBytes);
|
||||||
|
|
||||||
var bufferLength = this.bufferLength;
|
var bufferLength = this.bufferLength;
|
||||||
var buffer = this.ensureBuffer(bufferLength + pixBytes);
|
var buffer = this.ensureBuffer(bufferLength + rowBytes);
|
||||||
|
|
||||||
var currentRow = buffer.subarray(bufferLength, bufferLength + rowBytes);
|
var currentRow = buffer.subarray(bufferLength, bufferLength + rowBytes);
|
||||||
var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
|
var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
|
||||||
@ -833,7 +833,7 @@ var DecryptStream = (function() {
|
|||||||
var buffer = this.ensureBuffer(bufferLength + n);
|
var buffer = this.ensureBuffer(bufferLength + n);
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
buffer[bufferLength++] = chunk[i];
|
buffer[bufferLength++] = chunk[i];
|
||||||
this.bufferLength = n;
|
this.bufferLength = bufferLength;
|
||||||
this.eof = n < chunkSize;
|
this.eof = n < chunkSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1468,7 +1468,7 @@ var Parser = (function() {
|
|||||||
|
|
||||||
stream = stream.makeSubStream(pos, length, dict);
|
stream = stream.makeSubStream(pos, length, dict);
|
||||||
if (cipherTransform)
|
if (cipherTransform)
|
||||||
stream = cipherTransform.createString(stream);
|
stream = cipherTransform.createStream(stream);
|
||||||
stream = this.filter(stream, dict, length);
|
stream = this.filter(stream, dict, length);
|
||||||
stream.parameters = dict;
|
stream.parameters = dict;
|
||||||
return stream;
|
return stream;
|
||||||
@ -1802,7 +1802,11 @@ var XRef = (function() {
|
|||||||
}
|
}
|
||||||
error("bad XRef entry");
|
error("bad XRef entry");
|
||||||
}
|
}
|
||||||
e = parser.getObj(this.encrypt);
|
if (this.encrypt) {
|
||||||
|
e = parser.getObj(this.encrypt.createCipherTransform(num, gen));
|
||||||
|
} else {
|
||||||
|
e = parser.getObj();
|
||||||
|
}
|
||||||
// Don't cache streams since they are mutable.
|
// Don't cache streams since they are mutable.
|
||||||
if (!IsStream(e))
|
if (!IsStream(e))
|
||||||
this.cache[num] = e;
|
this.cache[num] = e;
|
||||||
@ -2629,7 +2633,7 @@ var CanvasGraphics = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (cmd == "Tf") { // eagerly collect all fonts
|
} else if (cmd == "Tf") { // eagerly collect all fonts
|
||||||
var fontRes; // = resources.get("Font");
|
var fontRes = resources.get("Font");
|
||||||
if (fontRes) {
|
if (fontRes) {
|
||||||
fontRes = xref.fetchIfRef(fontRes);
|
fontRes = xref.fetchIfRef(fontRes);
|
||||||
var font = xref.fetchIfRef(fontRes.get(args[0].name));
|
var font = xref.fetchIfRef(fontRes.get(args[0].name));
|
||||||
|
11
security.js
11
security.js
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
var ARCFourCipher = (function() {
|
var ARCFourCipher = (function() {
|
||||||
function constructor(key) {
|
function constructor(key) {
|
||||||
var key = this.key;
|
|
||||||
this.a = 0;
|
this.a = 0;
|
||||||
this.b = 0;
|
this.b = 0;
|
||||||
var s = new Uint8Array(256);
|
var s = new Uint8Array(256);
|
||||||
@ -133,13 +132,13 @@ var CipherTransform = (function() {
|
|||||||
}
|
}
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
createStream: function (stream) {
|
createStream: function (stream) {
|
||||||
var cipher = new streamCipherConstructor();
|
var cipher = new this.streamCipherConstructor();
|
||||||
return new DecryptStream(stream, function(data) {
|
return new DecryptStream(stream, function(data) {
|
||||||
return cipher.encryptBlock(data);
|
return cipher.encryptBlock(data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
decryptString: function(s) {
|
decryptString: function(s) {
|
||||||
var cipher = new stringCipherConstructor();
|
var cipher = new this.stringCipherConstructor();
|
||||||
var data = string2bytes(s);
|
var data = string2bytes(s);
|
||||||
data = cipher.encryptBlock(data);
|
data = cipher.encryptBlock(data);
|
||||||
return bytes2string(data);
|
return bytes2string(data);
|
||||||
@ -240,9 +239,9 @@ var CipherTransformFactory = (function() {
|
|||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
createCipherTransform: function(num, gen) {
|
createCipherTransform: function(num, gen) {
|
||||||
var encryptionKey = this.encryptionKey;
|
var encryptionKey = this.encryptionKey;
|
||||||
var key = new Uint8Array(encryptionKey.length + 5), i, j, n;
|
var key = new Uint8Array(encryptionKey.length + 5), i, n;
|
||||||
for (j = 0, n = encryptionKey.length; j < n; ++j)
|
for (i = 0, n = encryptionKey.length; i < n; ++i)
|
||||||
key[j] = encryptionKey[j];
|
key[i] = encryptionKey[i];
|
||||||
key[i++] = num & 0xFF;
|
key[i++] = num & 0xFF;
|
||||||
key[i++] = (num >> 8) & 0xFF;
|
key[i++] = (num >> 8) & 0xFF;
|
||||||
key[i++] = (num >> 16) & 0xFF;
|
key[i++] = (num >> 16) & 0xFF;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user