Skip to content

Filename too long #109

Open
Open

Description

@ggradwohl

HI. using this: (Contao 5.3.17)
_constructor(
#[Autowire('%kernel.project_dir%')] private readonly string $projectDir,
#[Autowire('@contao.image.factory')] private readonly ImageFactoryInterface $imageProcessor
)
...
$image = $this->imageProcessor->create(
$this->projectDir.'/'.$imagePath,
[1200, 1200, ResizeConfiguration::MODE_BOX],
(new ResizeOptions())->setTargetPath($this->projectDir.'/'.$imagePath),
);

creates a deferred-images Directory -> (with a *.json extension) wich has a too long file name (if the filename is too long:
"testöäüüö1´ß´13ß1´3ß sdfaasdfsafafd.fddsaf323423424afdsadfafdsfasdsaffsafdsa0ß9safd09sa0ß9fß09sadßf9fsa9ßaf0=$=!==§!=§!==!=!§=13ß01012ß300132aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-nav8sc9n33wem2p.jpg "
-> this lead to a backend crash in an content-element where you want to choose an image -> the Error" Could not rename", "filename too long" appears, and you are not able to choose an image

Activity

  1. self-assigned this
    on Nov 28, 2024
  2. ausi commented on Nov 28, 2024

    @ausi
    Member

    We need to limit the filename (including the extension) to 255 bytes here:

    return Path::join($hash[0], $pathinfo['filename'].'-'.substr($hash, 1).'.'.$extension);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions