Skip to content

Conversation

@bobvandevijver
Copy link
Member

Path calculation was broken after d007cf8. Instead, calculate the correct path earlier, and ensure path traversal is not possible.

Copilot AI review requested due to automatic review settings January 10, 2026 11:22
Copy link

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

@bobvandevijver bobvandevijver changed the base branch from 6.0 to 5.2 January 10, 2026 11:28
@bobvandevijver bobvandevijver force-pushed the fix-thumb-save branch 2 times, most recently from 6117e0c to f474950 Compare January 11, 2026 14:28
Path calculation was broken after d007cf8.
Instead, calculate the correct path earlier, and ensure path traversal is not possible.
@clem
Copy link
Contributor

clem commented Jan 11, 2026

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!

@bobvandevijver bobvandevijver merged commit 9b1444a into 5.2 Jan 12, 2026
20 checks passed
@bobvandevijver bobvandevijver deleted the fix-thumb-save branch January 12, 2026 07:18
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.

3 participants