diff --git a/cucumber/features/environment.py b/cucumber/features/environment.py index ca56b21f19..c85eb001d1 100644 --- a/cucumber/features/environment.py +++ b/cucumber/features/environment.py @@ -18,4 +18,4 @@ def after_scenario(context, scenario): # Remove any temporary files for temp_file in os.listdir('.'): if temp_file.startswith('genericNonCustomisableName') or temp_file.startswith('temp_image_'): - os.remove(temp_file) \ No newline at end of file + os.remove(temp_file) diff --git a/cucumber/features/steps/step_definitions.py b/cucumber/features/steps/step_definitions.py index ae8acd2adb..29b7ae18d9 100644 --- a/cucumber/features/steps/step_definitions.py +++ b/cucumber/features/steps/step_definitions.py @@ -42,7 +42,7 @@ def step_use_example_file(context, filePath, fileInput): context.file_name = filePath.split('/')[-1] if not hasattr(context, 'files'): context.files = {} - + # Ensure the file exists before opening try: example_file = open(filePath, 'rb') @@ -165,17 +165,17 @@ def step_pdf_contains_pages_with_random_text(context, page_count): buffer = io.BytesIO() c = canvas.Canvas(buffer, pagesize=letter) width, height = letter - + for _ in range(page_count): text = ''.join(random.choices(string.ascii_letters + string.digits, k=100)) c.drawString(100, height - 100, text) c.showPage() - + c.save() - + with open(context.file_name, 'wb') as f: f.write(buffer.getvalue()) - + context.files[context.param_name].close() context.files[context.param_name] = open(context.file_name, 'rb') @@ -184,16 +184,16 @@ def step_pdf_pages_contain_text(context, text): buffer = io.BytesIO() c = canvas.Canvas(buffer, pagesize=letter) width, height = letter - + for _ in range(len(PdfReader(context.file_name).pages)): c.drawString(100, height - 100, text) c.showPage() - + c.save() - + with open(context.file_name, 'wb') as f: f.write(buffer.getvalue()) - + context.files[context.param_name].close() context.files[context.param_name] = open(context.file_name, 'rb') @@ -354,7 +354,7 @@ def step_check_response_zip_doc_page_count(context, doc_count, pages_per_doc): with zipfile.ZipFile(io.BytesIO(response_file.getvalue())) as zip_file: actual_doc_count = len(zip_file.namelist()) assert actual_doc_count == doc_count, f"Expected {doc_count} documents but got {actual_doc_count} documents" - + for file_name in zip_file.namelist(): with zip_file.open(file_name) as pdf_file: reader = PdfReader(pdf_file) diff --git a/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml b/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml index 2ad3d999a8..3deddab448 100644 --- a/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml +++ b/exampleYmlFiles/docker-compose-latest-fat-security-postgres.yml @@ -60,4 +60,4 @@ services: timeout: 5s retries: 10 volumes: - - ./stirling/latest/data:/pgdata \ No newline at end of file + - ./stirling/latest/data:/pgdata diff --git a/scripts/counter_translation.py b/scripts/counter_translation.py index 7f17d37781..ba4ab67b9e 100644 --- a/scripts/counter_translation.py +++ b/scripts/counter_translation.py @@ -135,9 +135,10 @@ def compare_files( # elif "language.direction" in sort_ignore_translation[language]["missing"]: # sort_ignore_translation[language]["missing"].remove("language.direction") - with open(default_file_path, encoding="utf-8") as default_file, open( - file_path, encoding="utf-8" - ) as file: + with ( + open(default_file_path, encoding="utf-8") as default_file, + open(file_path, encoding="utf-8") as file, + ): for _ in range(5): next(default_file) try: diff --git a/src/main/resources/static/js/cacheFormInputs.js b/src/main/resources/static/js/cacheFormInputs.js index 1cd504b7f1..64760bf414 100644 --- a/src/main/resources/static/js/cacheFormInputs.js +++ b/src/main/resources/static/js/cacheFormInputs.js @@ -1,10 +1,10 @@ document.addEventListener("DOMContentLoaded", function() { - + var cacheInputs = localStorage.getItem("cacheInputs") || "disabled"; if (cacheInputs !== "enabled") { return; // Stop execution if caching is not enabled } - + // Function to generate a key based on the form's action attribute function generateStorageKey(form) { const action = form.getAttribute('action'); @@ -24,11 +24,11 @@ document.addEventListener("DOMContentLoaded", function() { for (let i = 0; i < elements.length; i++) { const element = elements[i]; // Skip elements without names, passwords, files, hidden fields, and submit/reset buttons - if (!element.name || - element.type === 'password' || - element.type === 'file' || - //element.type === 'hidden' || - element.type === 'submit' || + if (!element.name || + element.type === 'password' || + element.type === 'file' || + //element.type === 'hidden' || + element.type === 'submit' || element.type === 'reset') { continue; } diff --git a/src/main/resources/static/js/csrf.js b/src/main/resources/static/js/csrf.js index 2dc1c0ca22..20b8b00f16 100644 --- a/src/main/resources/static/js/csrf.js +++ b/src/main/resources/static/js/csrf.js @@ -18,7 +18,7 @@ document.addEventListener('DOMContentLoaded', function() { // Find all forms and add CSRF token const forms = document.querySelectorAll('form'); const csrfToken = decodeCsrfToken(getCsrfToken()); - + // Only proceed if we have a cookie-based token if (csrfToken) { forms.forEach(form => { @@ -34,4 +34,4 @@ document.addEventListener('DOMContentLoaded', function() { form.appendChild(csrfInput); }); } -}); \ No newline at end of file +}); diff --git a/src/main/resources/static/js/darkmode.js b/src/main/resources/static/js/darkmode.js index 08c0c380d4..abfe737c96 100644 --- a/src/main/resources/static/js/darkmode.js +++ b/src/main/resources/static/js/darkmode.js @@ -102,4 +102,4 @@ document.addEventListener("DOMContentLoaded", function () { toggleDarkMode(); }); } -}); \ No newline at end of file +}); diff --git a/src/main/resources/static/js/fetch-utils.js b/src/main/resources/static/js/fetch-utils.js index d606d71ac5..dfe2604a84 100644 --- a/src/main/resources/static/js/fetch-utils.js +++ b/src/main/resources/static/js/fetch-utils.js @@ -4,7 +4,7 @@ window.fetchWithCsrf = async function(url, options = {}) { .split('; ') .find(row => row.startsWith('XSRF-TOKEN=')) ?.split('=')[1]; - + if (cookieValue) { return cookieValue; } @@ -14,10 +14,10 @@ window.fetchWithCsrf = async function(url, options = {}) { // Create a new options object to avoid modifying the passed object const fetchOptions = { ...options }; - + // Ensure headers object exists fetchOptions.headers = { ...options.headers }; - + // Add CSRF token if available const csrfToken = getCsrfToken(); if (csrfToken) { @@ -25,4 +25,4 @@ window.fetchWithCsrf = async function(url, options = {}) { } return fetch(url, fetchOptions); -} \ No newline at end of file +} diff --git a/src/main/resources/static/js/game.js b/src/main/resources/static/js/game.js index 3746ef63dc..df04c5dd5d 100644 --- a/src/main/resources/static/js/game.js +++ b/src/main/resources/static/js/game.js @@ -32,8 +32,8 @@ function initializeGame() { const BASE_SPAWN_INTERVAL_MS = 1250; // milliseconds before a new enemy spawns const LEVEL_INCREASE_FACTOR_MS = 25; // milliseconds to decrease the spawn interval per level const MAX_SPAWN_RATE_REDUCTION_MS = 800; // Max milliseconds from the base spawn interval - - + + let keysPressed = {}; const pdfs = []; const projectiles = []; @@ -42,7 +42,7 @@ function initializeGame() { let pdfSpeed = BASE_PDF_SPEED; let gameOver = false; - + function handleKeys() { if (keysPressed["ArrowLeft"]) { playerX -= PLAYER_MOVE_SPEED; @@ -72,7 +72,7 @@ function initializeGame() { function onKeyUp(event) { keysPressed[event.key] = false; } - + document.removeEventListener("keydown", onKeydown); document.removeEventListener("keyup", onKeyUp); document.addEventListener("keydown", onKeydown); @@ -243,7 +243,7 @@ function initializeGame() { let spawnPdfTimeout; - + function spawnPdfInterval() { if (gameOver || paused) { diff --git a/src/main/resources/static/js/pipeline.js b/src/main/resources/static/js/pipeline.js index a1542b414f..50c6d662c0 100644 --- a/src/main/resources/static/js/pipeline.js +++ b/src/main/resources/static/js/pipeline.js @@ -222,30 +222,30 @@ document.getElementById('deletePipelineBtn').addEventListener('click', function( event.preventDefault(); let pipelineName = document.getElementById('pipelineName').value; - if (confirm(deletePipelineText + pipelineName)) { - removePipelineFromUI(pipelineName); - let key = "#Pipeline-" + pipelineName; - if (localStorage.getItem(key)) { - localStorage.removeItem(key); - } - let pipelineSelect = document.getElementById("pipelineSelect"); - let modal = document.getElementById('pipelineSettingsModal'); - if (modal.style.display !== 'none') { - $('#pipelineSettingsModal').modal('hide'); - } - - if (pipelineSelect.options.length > 0) { - pipelineSelect.selectedIndex = 0; - pipelineSelect.dispatchEvent(new Event('change')); - } + if (confirm(deletePipelineText + pipelineName)) { + removePipelineFromUI(pipelineName); + let key = "#Pipeline-" + pipelineName; + if (localStorage.getItem(key)) { + localStorage.removeItem(key); + } + let pipelineSelect = document.getElementById("pipelineSelect"); + let modal = document.getElementById('pipelineSettingsModal'); + if (modal.style.display !== 'none') { + $('#pipelineSettingsModal').modal('hide'); + } + + if (pipelineSelect.options.length > 0) { + pipelineSelect.selectedIndex = 0; + pipelineSelect.dispatchEvent(new Event('change')); + } } }); function removePipelineFromUI(pipelineName) { let pipelineSelect = document.getElementById("pipelineSelect"); for (let i = 0; i < pipelineSelect.options.length; i++) { - console.log(pipelineSelect.options[i]) - console.log("list " + pipelineSelect.options[i].innerText + " vs " + pipelineName) + console.log(pipelineSelect.options[i]) + console.log("list " + pipelineSelect.options[i].innerText + " vs " + pipelineName) if (pipelineSelect.options[i].innerText === pipelineName) { pipelineSelect.remove(i); break; @@ -415,17 +415,17 @@ document.getElementById("addOperationBtn").addEventListener("click", function () if (defaultValue === true) parameterInput.checked = true; break; case "array": - // If parameter.schema.format === 'binary' is to be checked, it should be checked here - parameterInput = document.createElement("textarea"); - parameterInput.placeholder = 'Enter a JSON formatted array, e.g., ["item1", "item2", "item3"]'; - parameterInput.className = "form-control"; - break; - case "object": - parameterInput = document.createElement("textarea"); - parameterInput.placeholder = 'Enter a JSON formatted object, e.g., {"key": "value"} If this is a fileInput, it is not currently supported'; - parameterInput.className = "form-control"; - break; - default: + // If parameter.schema.format === 'binary' is to be checked, it should be checked here + parameterInput = document.createElement("textarea"); + parameterInput.placeholder = 'Enter a JSON formatted array, e.g., ["item1", "item2", "item3"]'; + parameterInput.className = "form-control"; + break; + case "object": + parameterInput = document.createElement("textarea"); + parameterInput.placeholder = 'Enter a JSON formatted object, e.g., {"key": "value"} If this is a fileInput, it is not currently supported'; + parameterInput.className = "form-control"; + break; + default: parameterInput = document.createElement("input"); parameterInput.type = "text"; parameterInput.className = "form-control"; @@ -482,20 +482,20 @@ document.getElementById("addOperationBtn").addEventListener("click", function () case "array": case "object": if (value === null || value === "") { - settings[parameter.name] = ""; - } else { - try { - const parsedValue = JSON.parse(value); - if (Array.isArray(parsedValue)) { - settings[parameter.name] = parsedValue; - } else { - settings[parameter.name] = value; - } - } catch (e) { - settings[parameter.name] = value; - } - } - break; + settings[parameter.name] = ""; + } else { + try { + const parsedValue = JSON.parse(value); + if (Array.isArray(parsedValue)) { + settings[parameter.name] = parsedValue; + } else { + settings[parameter.name] = value; + } + } catch (e) { + settings[parameter.name] = value; + } + } + break; default: settings[parameter.name] = value; } @@ -686,13 +686,13 @@ async function processPipelineConfig(configString) { case "text": case "textarea": default: - var value = operationConfig.parameters[parameterName] - if (typeof value !== 'string') { - input.value = JSON.stringify(value) ; - } else { - input.value = value; - } - + var value = operationConfig.parameters[parameterName] + if (typeof value !== 'string') { + input.value = JSON.stringify(value) ; + } else { + input.value = value; + } + } } }); diff --git a/src/main/resources/static/js/settings.js b/src/main/resources/static/js/settings.js index 8f6289af22..6954913c50 100644 --- a/src/main/resources/static/js/settings.js +++ b/src/main/resources/static/js/settings.js @@ -39,4 +39,3 @@ document.getElementById("cacheInputs").addEventListener("change", function () { cacheInputs = this.checked ? "enabled" : "disabled"; localStorage.setItem("cacheInputs", cacheInputs); }); - diff --git a/src/main/resources/templates/account.html b/src/main/resources/templates/account.html index c26b93d0c8..01e17167a2 100644 --- a/src/main/resources/templates/account.html +++ b/src/main/resources/templates/account.html @@ -308,36 +308,36 @@

Settings Comparison:

document.getElementById('syncToAccount').addEventListener('click', async function() { /**/ - - let settings = {}; - for (let i = 0; i < localStorage.length; i++) { - const key = localStorage.key(i); - if(key !== 'debug' && key !== '0' && key !== '1' && !key.includes('pdfjs') && !key.includes('posthog') && !key.includes('pageViews')) { - settings[key] = localStorage.getItem(key); - } - } - - try { - const response = await window.fetchWithCsrf(urlUpdateUserSettings, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(settings) - }); - - if (response.ok) { - location.reload(); - } else { - alert('Error syncing settings to account'); - } - } catch (error) { - console.error('Error:', error); - alert('Error syncing settings to account'); - } - }); + const urlUpdateUserSettings = /*[[@{/api/v1/user/updateUserSettings}]]*/ "/api/v1/user/updateUserSettings"; + /*]]>*/ + + let settings = {}; + for (let i = 0; i < localStorage.length; i++) { + const key = localStorage.key(i); + if(key !== 'debug' && key !== '0' && key !== '1' && !key.includes('pdfjs') && !key.includes('posthog') && !key.includes('pageViews')) { + settings[key] = localStorage.getItem(key); + } + } + + try { + const response = await window.fetchWithCsrf(urlUpdateUserSettings, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(settings) + }); + + if (response.ok) { + location.reload(); + } else { + alert('Error syncing settings to account'); + } + } catch (error) { + console.error('Error:', error); + alert('Error syncing settings to account'); + } + }); }); diff --git a/src/main/resources/templates/fragments/footer.html b/src/main/resources/templates/fragments/footer.html index d18516c3cb..dea5d98413 100644 --- a/src/main/resources/templates/fragments/footer.html +++ b/src/main/resources/templates/fragments/footer.html @@ -16,8 +16,8 @@ + + Stirling PDF + \ No newline at end of file diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html index cee20450bf..1d205f405f 100644 --- a/src/main/resources/templates/login.html +++ b/src/main/resources/templates/login.html @@ -13,86 +13,86 @@
favicon diff --git a/src/main/resources/templates/releases.html b/src/main/resources/templates/releases.html index 36c18d1e8b..72beb17539 100644 --- a/src/main/resources/templates/releases.html +++ b/src/main/resources/templates/releases.html @@ -22,9 +22,9 @@
- +
@@ -113,9 +113,9 @@ const REPO_OWNER = 'Stirling-Tools'; const REPO_NAME = 'Stirling-PDF'; const GITHUB_API = 'https://api.github.com/repos/' + REPO_OWNER + '/' + REPO_NAME; - const GITHUB_URL = 'https://github.com/' + REPO_OWNER + '/' + REPO_NAME; - const MAX_RELEASES = 8; - + const GITHUB_URL = 'https://github.com/' + REPO_OWNER + '/' + REPO_NAME; + const MAX_RELEASES = 8; + // Secure element creation helper function createElement(tag, attributes = {}, children = []) { const element = document.createElement(tag); @@ -134,7 +134,7 @@ return element; } - + const ALLOWED_TAGS = { 'a': ['href', 'target', 'rel', 'class'], 'img': ['src', 'alt', 'width', 'height', 'style'], diff --git a/src/main/resources/templates/security/validate-signature.html b/src/main/resources/templates/security/validate-signature.html index 015f41ee61..af4e921321 100644 --- a/src/main/resources/templates/security/validate-signature.html +++ b/src/main/resources/templates/security/validate-signature.html @@ -21,9 +21,9 @@
- -
-
+ +
+
diff --git a/src/test/java/stirling/software/SPDF/SPDFApplicationTest.java b/src/test/java/stirling/software/SPDF/SPDFApplicationTest.java index e155527b76..fe17cedac4 100644 --- a/src/test/java/stirling/software/SPDF/SPDFApplicationTest.java +++ b/src/test/java/stirling/software/SPDF/SPDFApplicationTest.java @@ -29,7 +29,7 @@ public class SPDFApplicationTest { @Mock private ApplicationProperties applicationProperties; - + @InjectMocks private SPDFApplication SPDFApplication; diff --git a/src/test/java/stirling/software/SPDF/config/security/database/DatabaseConfigTest.java b/src/test/java/stirling/software/SPDF/config/security/database/DatabaseConfigTest.java index 2c61ce1a7e..bcfdc563c0 100644 --- a/src/test/java/stirling/software/SPDF/config/security/database/DatabaseConfigTest.java +++ b/src/test/java/stirling/software/SPDF/config/security/database/DatabaseConfigTest.java @@ -103,4 +103,4 @@ void exceptionThrown_whenDBTypeIsUnsupported(String datasourceType) { assertThrows(UnsupportedProviderException.class, () -> databaseConfig.dataSource()); } -} \ No newline at end of file +} diff --git a/src/test/java/stirling/software/SPDF/controller/api/RearrangePagesPDFControllerTest.java b/src/test/java/stirling/software/SPDF/controller/api/RearrangePagesPDFControllerTest.java index 03a6abb71c..6c68528660 100644 --- a/src/test/java/stirling/software/SPDF/controller/api/RearrangePagesPDFControllerTest.java +++ b/src/test/java/stirling/software/SPDF/controller/api/RearrangePagesPDFControllerTest.java @@ -98,4 +98,4 @@ void oddEvenMerge_multi_test(int totalNumberOfPages, String expectedPageOrder) { assertNotNull(newPageOrder, "Returning null instead of page order list"); assertEquals(Arrays.stream(expectedPageOrder.split(",")).map(Integer::parseInt).toList(), newPageOrder, "Page order doesn't match"); } -} \ No newline at end of file +}