From 7fa5e130d99227c2202ebddfdd91348176ec0c7b Mon Sep 17 00:00:00 2001 From: "stirlingbot[bot]" <195170888+stirlingbot[bot]@users.noreply.github.com> Date: Mon, 7 Jul 2025 10:05:50 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=96=20format=20everything=20with=20pre?= =?UTF-8?q?-commit=20by=20stirlingbot=20(#3882)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Auto-generated by [create-pull-request][1] with **stirlingbot** [1]: https://github.com/peter-evans/create-pull-request Signed-off-by: stirlingbot[bot] Co-authored-by: stirlingbot[bot] <195170888+stirlingbot[bot]@users.noreply.github.com> --- stirling-pdf/src/main/resources/static/js/DecryptFiles.js | 2 +- stirling-pdf/src/main/resources/static/js/downloader.js | 2 +- stirling-pdf/src/main/resources/static/js/fileInput.js | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/stirling-pdf/src/main/resources/static/js/DecryptFiles.js b/stirling-pdf/src/main/resources/static/js/DecryptFiles.js index 340773cb7..67349a012 100644 --- a/stirling-pdf/src/main/resources/static/js/DecryptFiles.js +++ b/stirling-pdf/src/main/resources/static/js/DecryptFiles.js @@ -125,7 +125,7 @@ export class DecryptFile { } else if (error.code === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) { return {isEncrypted: true, requiresPassword: false}; } - } else if (error.name === 'InvalidPDFException' || + } else if (error.name === 'InvalidPDFException' || (error.message && error.message.includes('Invalid PDF structure'))) { // Handle corrupted PDF files console.error('Corrupted PDF detected:', error); diff --git a/stirling-pdf/src/main/resources/static/js/downloader.js b/stirling-pdf/src/main/resources/static/js/downloader.js index c5a1a91db..301b0411b 100644 --- a/stirling-pdf/src/main/resources/static/js/downloader.js +++ b/stirling-pdf/src/main/resources/static/js/downloader.js @@ -238,7 +238,7 @@ ); throw decryptError; } - } else if (error.name === 'InvalidPDFException' || + } else if (error.name === 'InvalidPDFException' || (error.message && error.message.includes('Invalid PDF structure'))) { // Handle corrupted PDF files console.log(`Corrupted PDF detected: ${file.name}`, error); diff --git a/stirling-pdf/src/main/resources/static/js/fileInput.js b/stirling-pdf/src/main/resources/static/js/fileInput.js index b728792f1..71b6a1ebf 100644 --- a/stirling-pdf/src/main/resources/static/js/fileInput.js +++ b/stirling-pdf/src/main/resources/static/js/fileInput.js @@ -226,7 +226,7 @@ function setupFileInput(chooser) { try { const { isEncrypted, requiresPassword } = await decryptFile.checkFileEncrypted(file); - if (file.type === 'application/pdf' && isEncrypted && + if (file.type === 'application/pdf' && isEncrypted && !window.location.pathname.includes('remove-password')) { decryptedFile = await decryptFile.decryptFile(file, requiresPassword); if (!decryptedFile) throw new Error('File decryption failed.'); @@ -236,13 +236,13 @@ function setupFileInput(chooser) { } catch (error) { console.error(`Error decrypting file: ${file.name}`, error); - + // Check if this is a PDF corruption error if (error.message && error.message.includes('PDF file is corrupted')) { // The error banner is already shown by DecryptFiles.js, just continue with the file console.warn(`Continuing with corrupted PDF file: ${file.name}`); } - + if (!file.uniqueId) file.uniqueId = UUID.uuidv4(); return file; }