From 322e46259ac60bee6c7d9f25876a0aa1236067a4 Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Mon, 1 Mar 2021 14:18:33 +0100
Subject: [PATCH] Fix existing signatures not showing

They now check in multiple places for the signature, so replace all occurences.
To prevent this happening in the future also pin the release.
---
 package.json     | 2 +-
 rollup.config.js | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/package.json b/package.json
index 67366cc..5f47075 100644
--- a/package.json
+++ b/package.json
@@ -52,7 +52,7 @@
     "jszip": "^3.5.0",
     "lit-element": "^2.3.1",
     "lit-html": "^1.2.1",
-    "pdfjs-dist": "^2.4.456",
+    "pdfjs-dist": "2.6.347",
     "universal-router": "^9.0.1",
     "webdav": "^3.3.0"
   },
diff --git a/rollup.config.js b/rollup.config.js
index a2bdf4c..c428283 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -73,6 +73,9 @@ httpbin.org ${getOrigin(config.nextcloudBaseURL)} www.handy-signatur.at \
 ${getOrigin(config.pdfAsQualifiedlySigningServer)}; \
 img-src * blob: data:`;
 
+function replaceAll(string, search, replace) {
+    return string.split(search).join(replace);
+}
 
 export default (async () => {
     let privatePath = await getDistPath(pkg.name)
@@ -190,7 +193,7 @@ Dependencies:
                     src: await getPackagePath('pdfjs-dist', 'es5/build/pdf.worker.js'),
                     dest: 'dist/' + await getDistPath(pkg.name, 'pdfjs'),
                     // enable signatures in pdf preview
-                    transform: (contents) => contents.toString().replace('"Sig"', '"Sig-patched-show-anyway"')
+                    transform: (contents) => replaceAll(contents.toString(), '"Sig"', '"Sig-patched-show-anyway"')
                 },
                 {src: await getPackagePath('pdfjs-dist', 'cmaps/*'), dest: 'dist/' + await getDistPath(pkg.name, 'pdfjs')}, // do we want all map files?
                 {src: await getPackagePath('@dbp-toolkit/font-source-sans-pro', 'files/*'), dest: 'dist/' + await getDistPath(pkg.name, 'fonts/source-sans-pro')},
-- 
GitLab