From a8f76b2ce57d345b4587c401a369a53dbf3c2884 Mon Sep 17 00:00:00 2001 From: Sean Stoube <31805425+HoneyBearTech@users.noreply.github.com> Date: Sun, 22 Nov 2026 16:39:00 +0000 Subject: [PATCH] Require lowercase index in processing mode values Signed-off-by: Sean Stoube <31805425+HoneyBearTech@users.noreply.github.com> --- static/local-js/modules/processingMode.js | 3 ++- tests/js/libraryScheduling.test.js | 15 +++++++++++++-- tests/test_library_scheduling.py | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/static/local-js/modules/processingMode.js b/static/local-js/modules/processingMode.js index 8852aed8..a85bf450 100644 --- a/static/local-js/modules/processingMode.js +++ b/static/local-js/modules/processingMode.js @@ -6,7 +6,8 @@ export function validateProcessingMode (value) { if (Number.isSafeInteger(seconds) && seconds <= Date.now() / 1000 + 62135596800) return value throw new Error('Added duration is too large.') } - const index = value.match(/^index\(([a-z])(?:-([a-z])(#)?)?\)$/i) + // The keyword must be lowercase (server and Kometa schema); range letters may be either case. + const index = value.match(/^index\(([A-Za-z])(?:-([A-Za-z])(#)?)?\)$/) if (index) { if (index[1].toLowerCase() <= (index[2] || index[1]).toLowerCase()) return value throw new Error('Alphabetical range must be ascending, such as A-F.') diff --git a/tests/js/libraryScheduling.test.js b/tests/js/libraryScheduling.test.js index 57f71076..3d36a382 100644 --- a/tests/js/libraryScheduling.test.js +++ b/tests/js/libraryScheduling.test.js @@ -32,16 +32,27 @@ function change (input, value) { beforeEach(() => document.body.replaceChildren()) describe('processing mode contract', () => { - it.each(['full', 'diff', 'added(7)', 'added(30m)', 'added(1h)', 'added(12d)', 'index(A-F#)', 'index(A)', 'items(imdb:tt0133093|plex:42)'])('restores and validates %s', mode => { + it.each(['full', 'diff', 'added(7)', 'added(30m)', 'added(1h)', 'added(12d)', 'index(A-F#)', 'index(A)', 'index(A-F)', 'items(imdb:tt0133093|plex:42)'])('restores and validates %s', mode => { document.body.innerHTML = modeMarkup const root = document.querySelector('[data-processing-mode]') initProcessingMode(root, mode) expect(processingModeValue(root)).toBe(mode) expect(validateProcessingMode(mode)).toBe(mode) }) - it.each(['added(0)', 'added(-1)', 'added(1w)', 'added(999999999999)', 'index(Z-A)', 'items(42)', 'items(plex:0)', 'items(imdb:123)', 'full; ls'])('rejects %s', mode => { + it.each(['index(a-f)', 'index(a)', 'index(A-f#)'])('accepts lowercase range letters in %s', mode => { + expect(validateProcessingMode(mode)).toBe(mode) + }) + it.each(['added(0)', 'added(-1)', 'added(1w)', 'added(999999999999)', 'index(Z-A)', 'INDEX(A-F)', 'Index(a)', 'items(42)', 'items(plex:0)', 'items(imdb:123)', 'full; ls'])('rejects %s', mode => { expect(() => validateProcessingMode(mode)).toThrow() }) + it.each(['INDEX(A-F)', 'INDEX(a-f#)', 'Index(b)'])('still restores a saved %s into the dropdowns and rebuilds it as index(...)', saved => { + document.body.innerHTML = modeMarkup + const root = document.querySelector('[data-processing-mode]') + initProcessingMode(root, saved) + expect(root.querySelector('[data-processing-kind]').value).toBe('index') + expect(processingModeValue(root)).toMatch(/^index\([A-Z](-[A-Z]#?)?\)$/) + expect(() => validateProcessingMode(processingModeValue(root))).not.toThrow() + }) it('accepts comma and newline separated provider IDs', () => { document.body.innerHTML = modeMarkup const root = document.querySelector('[data-processing-mode]') diff --git a/tests/test_library_scheduling.py b/tests/test_library_scheduling.py index 8f44cd52..9212dc21 100644 --- a/tests/test_library_scheduling.py +++ b/tests/test_library_scheduling.py @@ -50,6 +50,7 @@ def test_finalized_processing_modes(mode): "added(1w)", "added(999999999999999999999)", "index(Z-A)", + "INDEX(A-F)", "index(A#)", "index(1-9)", "items(42)",