Closed
Description
Symfony version(s) affected
7.1.*
Description
When attempting to validate a file using the #[Assert\File] constraint, the filenameMaxLength of the filename is incorrectly calculated if the name contains non-Latin characters.
#[Assert\File(
maxSize: '10M',
mimeTypes: ['application/pdf'],
filenameMaxLength: 250,
)]
How to reproduce
- Create a file with a name containing more then 20 non-Latin characters.
- Validate the file using #[Assert\File] with the filenameMaxLength: 20 constraint.
- Observe the validation result.
Possible Solution
On line 143, the function strlen needs to be replaced with mb_strlen.
File: FileValidator
This will ensure proper handling of filenames containing multibyte characters, such as non-Latin characters, when calculating the string length.
Additional Context
No response