mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Guard no-JS file uploads: disabled filepond_mode by default, server-side fallback
The partage/admin form had a hardcoded filepond_mode=1 hidden input, so without JavaScript the server always entered the FilePond async path — which found no hex IDs and silently dropped all files. Three-layer fix: 1. HTML: filepond_mode input starts disabled with value=0; JS enables it and sets value=1 on DOMContentLoaded (and after HTMX swaps). Disabled inputs aren't submitted → server gets no filepond_mode → naturally falls to legacy path. 2. JS: enableFilepondMode() called on page load and hx:afterSwap so FilePond-enhanced forms always send filepond_mode=1. 3. Server (defense-in-depth): ThesisFileHandler::hasFilePondQueueData() scans POST['queue_file'] for 32-char hex IDs; ThesisCreateController and ThesisEditController use it alongside filepond_mode, so even if the flag somehow arrives without async upload IDs, the path takes over.
This commit is contained in:
4
TODO.md
4
TODO.md
@@ -52,8 +52,8 @@ Reference: Assessment against progressive-enhancement / WCAG-AA / "never lose da
|
||||
**Current state:** `form.php` hardcodes `<input type="hidden" name="filepond_mode" value="1">`. Without JS, no `queue_file[]` hidden inputs are populated → server gets `filepond_mode=1` with empty queue → all files silently dropped. The form is supposed to work without JS.
|
||||
|
||||
**To do:**
|
||||
- [ ] Change the hidden input to `<input type="hidden" name="filepond_mode" value="0" disabled>` by default; JS enables it and sets `value="1"` on DOMContentLoaded
|
||||
- [ ] Add server-side fallback in `ThesisCreateController::submit()` and `ThesisEditController::save()`: when `filepond_mode=1` but no `queue_file` data is present, fall through to the legacy `$_FILES` path
|
||||
- [x] Change the hidden input to `<input type="hidden" name="filepond_mode" value="0" disabled>` by default; JS enables it and sets `value="1"` on DOMContentLoaded
|
||||
- [x] Add server-side fallback in `ThesisCreateController::submit()` and `ThesisEditController::save()`: when `filepond_mode=1` but no `queue_file` data is present, fall through to the legacy `$_FILES` path
|
||||
- [ ] Test end-to-end: submit the partage form with JS disabled, verify files arrive via `$_FILES`
|
||||
|
||||
### 3. Autosave text fields on partage form
|
||||
|
||||
Reference in New Issue
Block a user