From 382edc01f88e1e10b79df01072d06420f1bf6b23 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Fri, 23 Aug 2024 10:17:50 +0200 Subject: [PATCH] Multiple flag fix (#1742) * fix * multiple file logic cleanup * fix --------- Co-authored-by: a --- .../SPDF/config/security/UserService.java | 1 - .../software/SPDF/utils/GeneralUtils.java | 29 ++++++++++--------- src/main/resources/static/js/downloader.js | 2 +- .../resources/templates/auto-split-pdf.html | 2 +- .../templates/convert/book-to-pdf.html | 2 +- .../templates/convert/file-to-pdf.html | 2 +- .../templates/convert/html-to-pdf.html | 2 +- .../templates/convert/img-to-pdf.html | 2 +- .../templates/convert/markdown-to-pdf.html | 2 +- .../templates/convert/pdf-to-book.html | 2 +- .../templates/convert/pdf-to-csv.html | 2 +- .../templates/convert/pdf-to-html.html | 2 +- .../templates/convert/pdf-to-img.html | 2 +- .../templates/convert/pdf-to-pdfa.html | 2 +- .../convert/pdf-to-presentation.html | 2 +- .../templates/convert/pdf-to-text.html | 2 +- .../templates/convert/pdf-to-word.html | 2 +- .../templates/convert/pdf-to-xml.html | 2 +- src/main/resources/templates/crop.html | 2 +- .../resources/templates/extract-page.html | 2 +- .../resources/templates/fragments/common.html | 7 +++-- src/main/resources/templates/merge-pdfs.html | 2 +- .../resources/templates/misc/add-image.html | 4 +-- .../templates/misc/add-page-numbers.html | 2 +- .../templates/misc/adjust-contrast.html | 2 +- .../resources/templates/misc/auto-crop.html | 2 +- .../resources/templates/misc/auto-rename.html | 2 +- .../templates/misc/change-metadata.html | 2 +- .../resources/templates/misc/compare.html | 4 +-- .../templates/misc/compress-pdf.html | 2 +- .../templates/misc/extract-image-scans.html | 2 +- .../templates/misc/extract-images.html | 2 +- .../resources/templates/misc/fake-scan.html | 2 +- .../resources/templates/misc/flatten.html | 2 +- .../resources/templates/misc/ocr-pdf.html | 2 +- .../resources/templates/misc/print-file.html | 2 +- .../templates/misc/remove-annotations.html | 2 +- .../templates/misc/remove-blanks.html | 2 +- src/main/resources/templates/misc/repair.html | 2 +- .../templates/misc/show-javascript.html | 2 +- src/main/resources/templates/misc/stamp.html | 2 +- .../templates/multi-page-layout.html | 2 +- src/main/resources/templates/overlay-pdf.html | 4 +-- .../resources/templates/pdf-organizer.html | 2 +- .../templates/pdf-to-single-page.html | 2 +- src/main/resources/templates/pipeline.html | 2 +- .../resources/templates/remove-image-pdf.html | 2 +- .../resources/templates/remove-pages.html | 2 +- src/main/resources/templates/rotate-pdf.html | 2 +- src/main/resources/templates/scale-pages.html | 2 +- .../templates/security/add-password.html | 2 +- .../templates/security/add-watermark.html | 2 +- .../templates/security/cert-sign.html | 10 +++---- .../security/change-permissions.html | 2 +- .../templates/security/get-info-on-pdf.html | 2 +- .../templates/security/remove-cert-sign.html | 2 +- .../templates/security/remove-password.html | 2 +- .../templates/security/remove-watermark.html | 2 +- .../templates/security/sanitize-pdf.html | 2 +- src/main/resources/templates/sign.html | 4 +-- .../templates/split-by-size-or-count.html | 2 +- .../templates/split-pdf-by-sections.html | 2 +- src/main/resources/templates/split-pdfs.html | 2 +- 63 files changed, 87 insertions(+), 86 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/config/security/UserService.java b/src/main/java/stirling/software/SPDF/config/security/UserService.java index 7b8c5ff0..b1b51596 100644 --- a/src/main/java/stirling/software/SPDF/config/security/UserService.java +++ b/src/main/java/stirling/software/SPDF/config/security/UserService.java @@ -22,7 +22,6 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.oauth2.core.user.OAuth2User; import org.springframework.stereotype.Service; -import lombok.extern.slf4j.Slf4j; import stirling.software.SPDF.config.DatabaseBackupInterface; import stirling.software.SPDF.config.security.session.SessionPersistentRegistry; import stirling.software.SPDF.controller.api.pipeline.UserServiceInterface; diff --git a/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java b/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java index aa5f3aea..1efd2446 100644 --- a/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java +++ b/src/main/java/stirling/software/SPDF/utils/GeneralUtils.java @@ -4,7 +4,9 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.net.HttpURLConnection; import java.net.MalformedURLException; +import java.net.URL; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; @@ -13,8 +15,6 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; -import java.net.URL; -import java.net.HttpURLConnection; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,8 +73,7 @@ public class GeneralUtils { } catch (MalformedURLException e) { return false; } - - } + } public static boolean isURLReachable(String urlStr) { try { @@ -112,16 +111,19 @@ public class GeneralUtils { sizeStr = sizeStr.replace(",", ".").replace(" ", ""); try { if (sizeStr.endsWith("KB")) { - return (long) (Double.parseDouble(sizeStr.substring(0, sizeStr.length() - 2)) * 1024); + return (long) + (Double.parseDouble(sizeStr.substring(0, sizeStr.length() - 2)) * 1024); } else if (sizeStr.endsWith("MB")) { - return (long) (Double.parseDouble(sizeStr.substring(0, sizeStr.length() - 2)) - * 1024 - * 1024); + return (long) + (Double.parseDouble(sizeStr.substring(0, sizeStr.length() - 2)) + * 1024 + * 1024); } else if (sizeStr.endsWith("GB")) { - return (long) (Double.parseDouble(sizeStr.substring(0, sizeStr.length() - 2)) - * 1024 - * 1024 - * 1024); + return (long) + (Double.parseDouble(sizeStr.substring(0, sizeStr.length() - 2)) + * 1024 + * 1024 + * 1024); } else if (sizeStr.endsWith("B")) { return Long.parseLong(sizeStr.substring(0, sizeStr.length() - 1)); } else { @@ -191,8 +193,7 @@ public class GeneralUtils { // Check if the result is null or not within bounds if (result == null || result <= 0 || result.intValue() > maxValue) { - if (n != 0) - break; + if (n != 0) break; } else { results.add(result.intValue()); } diff --git a/src/main/resources/static/js/downloader.js b/src/main/resources/static/js/downloader.js index c955bb1b..87d2670a 100644 --- a/src/main/resources/static/js/downloader.js +++ b/src/main/resources/static/js/downloader.js @@ -37,7 +37,7 @@ $(document).ready(function () { try { if (remoteCall === true) { - if (override === "multi" || (!multiple && files.length > 1 && override !== "single")) { + if (override === "multi" || (!multipleInputsForSingleRequest && files.length > 1 && override !== "single")) { await submitMultiPdfForm(url, files); } else { await handleSingleDownload(url, formData); diff --git a/src/main/resources/templates/auto-split-pdf.html b/src/main/resources/templates/auto-split-pdf.html index 06915a47..2ef7e23d 100644 --- a/src/main/resources/templates/auto-split-pdf.html +++ b/src/main/resources/templates/auto-split-pdf.html @@ -24,7 +24,7 @@

+ th:replace="~{fragments/common :: fileSelector(name='fileInput', multipleInputsForSingleRequest=false, accept='application/pdf')}">
diff --git a/src/main/resources/templates/convert/book-to-pdf.html b/src/main/resources/templates/convert/book-to-pdf.html index 926fe7c3..2de6011f 100644 --- a/src/main/resources/templates/convert/book-to-pdf.html +++ b/src/main/resources/templates/convert/book-to-pdf.html @@ -15,7 +15,7 @@

-
+

diff --git a/src/main/resources/templates/convert/file-to-pdf.html b/src/main/resources/templates/convert/file-to-pdf.html index c5e7b8ad..23b88b8f 100644 --- a/src/main/resources/templates/convert/file-to-pdf.html +++ b/src/main/resources/templates/convert/file-to-pdf.html @@ -21,7 +21,7 @@

-
+
diff --git a/src/main/resources/templates/convert/html-to-pdf.html b/src/main/resources/templates/convert/html-to-pdf.html index 511e7758..9ed186be 100644 --- a/src/main/resources/templates/convert/html-to-pdf.html +++ b/src/main/resources/templates/convert/html-to-pdf.html @@ -18,7 +18,7 @@
-
+
diff --git a/src/main/resources/templates/convert/img-to-pdf.html b/src/main/resources/templates/convert/img-to-pdf.html index b71afaf8..755f6b5a 100644 --- a/src/main/resources/templates/convert/img-to-pdf.html +++ b/src/main/resources/templates/convert/img-to-pdf.html @@ -18,7 +18,7 @@
-
+
diff --git a/src/main/resources/templates/convert/pdf-to-csv.html b/src/main/resources/templates/convert/pdf-to-csv.html index 60dd06b4..98d2d80e 100644 --- a/src/main/resources/templates/convert/pdf-to-csv.html +++ b/src/main/resources/templates/convert/pdf-to-csv.html @@ -18,7 +18,7 @@
-
+
diff --git a/src/main/resources/templates/convert/pdf-to-html.html b/src/main/resources/templates/convert/pdf-to-html.html index 4843eead..833940c0 100644 --- a/src/main/resources/templates/convert/pdf-to-html.html +++ b/src/main/resources/templates/convert/pdf-to-html.html @@ -18,7 +18,7 @@
-
+

diff --git a/src/main/resources/templates/convert/pdf-to-img.html b/src/main/resources/templates/convert/pdf-to-img.html index e9f03c16..cc0b28f5 100644 --- a/src/main/resources/templates/convert/pdf-to-img.html +++ b/src/main/resources/templates/convert/pdf-to-img.html @@ -19,7 +19,7 @@

-
+
diff --git a/src/main/resources/templates/convert/pdf-to-presentation.html b/src/main/resources/templates/convert/pdf-to-presentation.html index ce1f455d..c52419f3 100644 --- a/src/main/resources/templates/convert/pdf-to-presentation.html +++ b/src/main/resources/templates/convert/pdf-to-presentation.html @@ -18,7 +18,7 @@
-
+
diff --git a/src/main/resources/templates/convert/pdf-to-word.html b/src/main/resources/templates/convert/pdf-to-word.html index 0fd004f2..1b3f7f58 100644 --- a/src/main/resources/templates/convert/pdf-to-word.html +++ b/src/main/resources/templates/convert/pdf-to-word.html @@ -18,7 +18,7 @@
-
+
diff --git a/src/main/resources/templates/extract-page.html b/src/main/resources/templates/extract-page.html index 8413bc88..47db4400 100644 --- a/src/main/resources/templates/extract-page.html +++ b/src/main/resources/templates/extract-page.html @@ -17,7 +17,7 @@
-
+
diff --git a/src/main/resources/templates/fragments/common.html b/src/main/resources/templates/fragments/common.html index f790f6c6..4ec8ce00 100644 --- a/src/main/resources/templates/fragments/common.html +++ b/src/main/resources/templates/fragments/common.html @@ -144,17 +144,18 @@ - +
- +
diff --git a/src/main/resources/templates/merge-pdfs.html b/src/main/resources/templates/merge-pdfs.html index f7d35684..8e1e0fbc 100644 --- a/src/main/resources/templates/merge-pdfs.html +++ b/src/main/resources/templates/merge-pdfs.html @@ -20,7 +20,7 @@
-
+
diff --git a/src/main/resources/templates/misc/add-image.html b/src/main/resources/templates/misc/add-image.html index e60e271b..a625864c 100644 --- a/src/main/resources/templates/misc/add-image.html +++ b/src/main/resources/templates/misc/add-image.html @@ -20,7 +20,7 @@
-
+
-
+