From 180d82a72feb2085e9d60d5f0ae5c7eab0807d27 Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Tue, 12 Jan 2021 14:26:54 +0100 Subject: [PATCH] qual-sig: Fix URL escaping when fetching the file There was a workaround for deriving the filename from the source filename because characters like '#' didn't make it through. Turns out this was just a bug some lines above where encodeURIComponent() wasn't used as it should. Use encodeURIComponent() when constructing the URL and remove the workaround. --- src/dbp-qualified-signature-pdf-upload.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/dbp-qualified-signature-pdf-upload.js b/src/dbp-qualified-signature-pdf-upload.js index f382da9..ccac700 100644 --- a/src/dbp-qualified-signature-pdf-upload.js +++ b/src/dbp-qualified-signature-pdf-upload.js @@ -278,8 +278,8 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle // fetch pdf from api gateway with sessionId JSONLD.initialize(this.entryPointUrl, (jsonld) => { - const apiUrl = jsonld.getApiUrlForEntityName("QualifiedlySignedDocument") + '/' + sessionId + '?fileName=' + - encodeURI(fileName); + const apiUrl = jsonld.getApiUrlForEntityName("QualifiedlySignedDocument") + '/' + encodeURIComponent(sessionId) + '?fileName=' + + encodeURIComponent(fileName); fetch(apiUrl, { headers: { @@ -298,8 +298,6 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle return result.json(); }) .then((document) => { - // PDF-AS garbles some filenames (e.g. containing a '#') - document.signedFilename = this.currentFileName.replace(/\.pdf$/i, '.sig.pdf'); // this doesn't seem to trigger an update() execution that.signedFiles.push(document); // this triggers the correct update() execution @@ -793,7 +791,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(DBPSignatureLitEle results.push(html` <div class="file-block"> <div class="header"> - <span class="filename"><strong>${file.signedFilename}</strong> (${humanFileSize(file.contentSize)})</span> + <span class="filename"><strong>${file.name}</strong> (${humanFileSize(file.contentSize)})</span> <button class="button close" title="${i18n.t('qualified-pdf-upload.download-file-button-title')}" @click="${() => { this.downloadFileClickHandler(file); }}"> -- GitLab