1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

[Annotation] Avoid to encrypt the appearance stream two times (bug 1815476)

This commit is contained in:
Calixte Denizet 2023-02-07 19:26:46 +01:00
parent c971f4a0a9
commit ea7b4b4d6c
6 changed files with 34 additions and 19 deletions

View file

@ -1894,13 +1894,11 @@ class WidgetAnnotation extends Annotation {
let newTransform = null;
if (encrypt) {
newTransform = encrypt.createCipherTransform(newRef.num, newRef.gen);
appearance = newTransform.encryptString(appearance);
}
const resources = this._getSaveFieldResources(xref);
const appearanceStream = new StringStream(appearance);
const appearanceDict = (appearanceStream.dict = new Dict(xref));
appearanceDict.set("Length", appearance.length);
appearanceDict.set("Subtype", Name.get("Form"));
appearanceDict.set("Resources", resources);
appearanceDict.set("BBox", [
@ -3669,7 +3667,6 @@ class FreeTextAnnotation extends MarkupAnnotation {
appearanceStreamDict.set("Subtype", Name.get("Form"));
appearanceStreamDict.set("Type", Name.get("XObject"));
appearanceStreamDict.set("BBox", [0, 0, w, h]);
appearanceStreamDict.set("Length", appearance.length);
appearanceStreamDict.set("Resources", resources);
if (rotation) {

View file

@ -45,13 +45,13 @@ function writeDict(dict, buffer, transform) {
}
function writeStream(stream, buffer, transform) {
writeDict(stream.dict, buffer, transform);
buffer.push(" stream\n");
let string = stream.getString();
if (transform !== null) {
string = transform.encryptString(string);
}
buffer.push(string, "\nendstream");
stream.dict.set("Length", string.length);
writeDict(stream.dict, buffer, transform);
buffer.push(" stream\n", string, "\nendstream");
}
function writeArray(array, buffer, transform) {