Closed AddMoreScripts closed 2 years ago
The namer is not meant to cover all possible situations, only the most common ones. If you have this need, you can always implement your own namer.
@garak: There is clearly a logical bug if the filename is split twice :confused: e.g. "раз1.раз2.раз3.jpg" gives "raz1-raz2.раз3.jpg" ("раз1.раз2.раз3.jpg" is first split to "раз1.раз2.раз3" + "jpg", then "раз1.раз2.раз3" is split again to "раз1.раз2" + "раз3", then only "раз1.раз2" is sluggified to "raz1-raz2")
It's not a bug. It's by design, and it covers 99% of cases.
So you are saying that double-splitting the extension, resulting in this (vertical table):
Input | раз1.jpg | раз1.раз2.jpg | раз1.раз2.раз3.jpg | раз1.раз2.раз3.раз4.jpg |
---|---|---|---|---|
Output | raz1.jpg | raz1.раз2.jpg | raz1-raz2.раз3.jpg | raz1-raz2-raz3.раз4.jpg |
is by design... :confused: Anyway, I don't want to argue more
You can use your own namer, or add a validation to disallow files with additional dots.
Bug Report
Summary
I noticed that if the file name contains two or more dots in the name, then transliteration occurs only up to the first dot. For instance:
Current behavior
раз.два.jpg
->raz.два.jpg
How to reproduce
Set in config vich_uploader.yaml namer option:
namer: Vich\UploaderBundle\Naming\SlugNamer
and upload file named with dotраз.два.jpg
Expected behavior
The file name must be fully translated, possibly replacing the dot with another character
Possible problem solution
in file
/src/Naming/SlugNamer.php
in methodname()
:There is a separation of the file name and extension, and then it is sent to the
transliterate
method of theTransliterator
class. But in transliterate() methodFilenameUtils::spitNameByExtension
is used and split filename again, and transliterate only first part.It seems to me that we can simply pass the original file name
$originalName
with the extension to the method$this->transliterator->transliterate()
without split it twice.But maybe I'm wrong.