Filenames with slashes in volume filtering#1466
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes volume filename filtering for files whose names begin with / (e.g., remote videos), which previously caused routing/errors when the filename pattern contained a leading slash (issue #1123).
Changes:
- Allow the
filenamefilter route parameter to include slashes by widening the route constraint. - URL-encode filename patterns on the frontend before sending them as a path parameter.
- Decode percent-encoded filename patterns in the API controller, and extend test coverage for slash/encoding edge cases.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/php/Http/Controllers/Api/Volumes/Filters/FilenameControllerTest.php | Adds test cases covering leading-slash patterns and percent-encoding behavior. |
| routes/api.php | Updates the filename filter route to accept patterns containing / via a permissive regex. |
| resources/assets/js/volumes/stores/filters.js | Encodes filename patterns before calling the API so leading slashes don’t break routing. |
| resources/assets/js/volumes/cloneForm.vue | Encodes the clone form’s file pattern when querying matching filenames. |
| app/Http/Controllers/Api/Volumes/Filters/FilenameController.php | Decodes percent-encoded patterns server-side before applying filtering logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| $router->get('{id}/files/filter/filename/{pattern}', [ | ||
| 'uses' => 'Filters\FilenameController@index', | ||
| ]); | ||
| ])->where('pattern', '.*'); |
There was a problem hiding this comment.
After additional investigation:
- Laravel already encodes/decodes URI components
- However, laravel decodes the route parameters and throws an exception if the decoded pattern contains invalid characters such as slashes
- 2 possible fixes:
- encode/decode manually on top of vue/laravel encoding/decoding, then laravel can't "see" the invalid characters after decoding the pattern just once
- add the
->where('pattern', '.*');to explicitly allow any characters, including slashes
The second approach is actually cleaner so I'll remove the manual encoding/decoding
There was a problem hiding this comment.
Please add a comment here why this is used, then. And you think we shouldn't use encodeURIComponent in JS as well? Is seems a safer bet.
Closes #1123