IBX-11681: Added filename validation in DownloadController and corresponding tests#756
Open
wiewiurdp wants to merge 2 commits into
Open
Conversation
aa0bf1c to
1ba641c
Compare
1ba641c to
93d53c1
Compare
mikadamczyk
reviewed
May 28, 2026
Contributor
mikadamczyk
left a comment
There was a problem hiding this comment.
Could we add an integration test for URL-encoded filenames here? Since the new check uses strict equality $field->value->fileName !== $filename, any encoding or decoding differences in the real request flow may cause valid downloads to be rejected as NotFound. Especially for spaces or special characters.
konradoboza
reviewed
May 29, 2026
Contributor
konradoboza
left a comment
There was a problem hiding this comment.
Looks good but I think providing the test case that Mikołaj has mentioned makes sense.
| @@ -0,0 +1,142 @@ | |||
| <?php | |||
|
|
|||
Contributor
There was a problem hiding this comment.
Declaring strict types is missing.
Comment on lines
+29
to
+30
| /** @var \Ibexa\Contracts\Core\Repository\ContentService|\PHPUnit\Framework\MockObject\MockObject */ | ||
| private $contentService; |
Contributor
There was a problem hiding this comment.
Please apply the similar to the other properties:
Suggested change
| /** @var \Ibexa\Contracts\Core\Repository\ContentService|\PHPUnit\Framework\MockObject\MockObject */ | |
| private $contentService; | |
| /** @var \Ibexa\Contracts\Core\Repository\ContentService&\PHPUnit\Framework\MockObject\MockObject */ | |
| private ContentService $contentService; |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Description:
Added filename validation to the content download endpoint for binary files.
Previously,
/content/download/{contentId}/{fieldIdentifier}/{filename}accepted anyfilenamevalue from the URL and still returned the file as long ascontentIdandfieldIdentifiermatched an accessible field. This made it possible to enumerate downloadable files more easily by guessing content identifiers and reusing common field identifiers such asfile.This change makes the download controller verify that the
filenameprovided in the URL matches the actual file name stored in the field value. If it does not match, the controller now returnsNotFoundExceptionbefore loading the binary file from storage.