From 821ea77a8d593b63108b804b917d7a73696095da Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Thu, 10 Feb 2022 13:17:02 +0100 Subject: [PATCH] Fix signature detection for QPDF-367-0.pdf We added QPDF-367-0.pdf as a regression test, but it also contains a different type of signature we don't currently support. Since we already have it in tree extend the regex to also detect it. --- src/utils.js | 2 +- test/unit.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.js b/src/utils.js index 11c29c7..32246a9 100644 --- a/src/utils.js +++ b/src/utils.js @@ -132,7 +132,7 @@ export const readArrayBufferFileContent = async (file) => { */ export const getPDFSignatureCount = async (file) => { const sigRegex = new RegExp( - '/Type\\s*/Sig[\\s\\S]*?/SubFilter\\s*(/ETSI\\.CAdES\\.detached|/adbe\\.pkcs7\\.detached)', + '(/Type\\s*/Sig|/Filter\\s*/Adobe.PPKLite)[\\s\\S]*?/SubFilter\\s*(/ETSI\\.CAdES\\.detached|/adbe\\.pkcs7\\.detached)', 'g' ); const content = await readBinaryFileContent(file); diff --git a/test/unit.js b/test/unit.js index 82895c1..4b806d5 100644 --- a/test/unit.js +++ b/test/unit.js @@ -76,7 +76,7 @@ suite('pdf signature detection', () => { return getPDFFile(await resp.arrayBuffer()); } - assert.equal((await getPDFSignatureCount(await getRealPDFFile('QPDF-367-0.pdf'))), 0); + assert.equal((await getPDFSignatureCount(await getRealPDFFile('QPDF-367-0.pdf'))), 1); assert.equal((await getPDFSignatureCount(await getRealPDFFile('qual-sig-simple.pdf'))), 1); assert.equal((await getPDFSignatureCount(await getRealPDFFile('qual-sig-tugraz-multiple.pdf'))), 2); }); -- GitLab