Skip to content

Filenames with slashes in volume filtering#1466

Open
yannik131 wants to merge 5 commits into
masterfrom
1123-filenames-with-slash
Open

Filenames with slashes in volume filtering#1466
yannik131 wants to merge 5 commits into
masterfrom
1123-filenames-with-slash

Conversation

@yannik131
Copy link
Copy Markdown
Contributor

Closes #1123

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 filename filter 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.

Comment thread tests/php/Http/Controllers/Api/Volumes/Filters/FilenameControllerTest.php Outdated
Comment thread tests/php/Http/Controllers/Api/Volumes/Filters/FilenameControllerTest.php Outdated
Comment thread resources/assets/js/volumes/stores/filters.js
Comment thread resources/assets/js/volumes/cloneForm.vue Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@yannik131 yannik131 marked this pull request as ready for review May 21, 2026 10:16
@yannik131 yannik131 requested a review from mzur May 21, 2026 10:16
Comment thread routes/api.php
$router->get('{id}/files/filter/filename/{pattern}', [
'uses' => 'Filters\FilenameController@index',
]);
])->where('pattern', '.*');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this if it matches anything?

Copy link
Copy Markdown
Contributor Author

@yannik131 yannik131 May 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After additional investigation:

  • Laravel and vue already encode/decode 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

@yannik131 yannik131 requested a review from mzur May 22, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filtering filenames that begin with a slash results in an error

3 participants