Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the thumbnail save location path calculation, which was broken after commit d007cf8. The fix calculates the correct thumbnail path earlier in the process and ensures path traversal attacks are prevented through proper canonicalization.
Changes:
- Moved thumbnail path calculation to earlier in the
thumbnail()method with proper canonicalization - Updated
saveAsFile()method signature to accept pre-calculated thumbnail path instead of calculating it internally - Removed inline path construction in favor of the canonicalized path
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9e9db6b to
4b9631b
Compare
4b9631b to
4411c37
Compare
6117e0c to
f474950
Compare
Path calculation was broken after d007cf8. Instead, calculate the correct path earlier, and ensure path traversal is not possible.
f474950 to
e1571fd
Compare
Contributor
|
Just needed to update the top of the class with this code for Bolt 6.0: class ImageController
{
private Server $server;
/**
* @var array{
* w?: int,
* h?: int,
* fit?: string,
* location?: string,
* q?: int
* }
*/
private array $parameters = [];
private Request $request;
public function __construct(
private readonly Config $config
) {
}
#[Route(path: '/thumbs/{paramString}/{filename}', name: 'thumbnail', requirements: ['filename' => '.+'], methods: [Request::METHOD_GET])]
public function thumbnail(Request $request, string $paramString, string $filename): Response
{
$this->request = $request;
if (!$this->isImage($filename)) {
return $this->sendErrorImage();
}
// ...And thanks a lot because it works! |
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.
Path calculation was broken after d007cf8. Instead, calculate the correct path earlier, and ensure path traversal is not possible.