Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filename too long #109

Open
ggradwohl opened this issue Nov 28, 2024 · 1 comment
Open

Filename too long #109

ggradwohl opened this issue Nov 28, 2024 · 1 comment
Assignees
Labels

Comments

@ggradwohl
Copy link

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

@ausi ausi added the bug label Nov 28, 2024
@ausi ausi self-assigned this Nov 28, 2024
@ausi
Copy link
Member

ausi commented Nov 28, 2024

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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants