revolution
revolution copied to clipboard
Filesystem stripping periods from folder names
Bug report
Summary
I have a client who likes to use periods in the file structure, so their images in the filesystem have paths like "assets/images/3. Category/SomeImage.png". This has worked fine for many years. However, recently, in 3.0.2, if you click that "3. Category" folder in the Filesystem browser in the admin, the hierarchy no longer expands to show the images inside the folder. Instead, you get this error:
Unable to retrieve the mime_type for file at location: assets/images/3 Category. finfo::file(/www/assets/images/3 Category): failed to open stream: No such file or directory
Notice that the error has stripped out the period after "3" -- it is looking for the folder "3 Category" instead of "3. Category", and not finding it. The folder and files are all still there and able to be used as src files on the frontend via direct URL (ex. "www.example.com/assets/images/3.%20Category/SomeImage.png"), but the backend manager can no longer edit or see these files. This whole setup works fine in an older, 3.0.1 development setup I have kicking around. One other different behavior I noticed is that if you try to create a new folder through the manager UI, say "4. Example", that will generate a "4. Example" folder in my 3.0.1 setup, but on 3.0.2 it generates a "4 Example" folder with period stripped.
This may not be a version issue -- it is very possible that a system setting somewhere has been changed to disallow periods in folder names, but if so, I've looked over the FURL settings and I don't see any specific period restrictions. Pasting my FURL settings below.
Step to reproduce
Open Filesystem, click a folder with a period in its name.
Observed behavior
This error is shown:
Expected behavior
The folder expands and shows child items in the hierarchy.
Environment
MODX 3.0.2
This is likely related to the upload_translit system setting, or a separate extra like FileSluggy. See if you have the latter one installed, and if not disable the former.
It seems this bug was introduce in MODX 3.0.2 by #16249.
This line in the code
https://github.com/modxcms/revolution/blob/ad6977df46b2d153c5696968f0fdff76e0a99839/core/src/Revolution/Processors/Browser/Browser.php#L146
deletes the . in the directory path, if there is (for example) a space after it.
A folder with the name "3. Category" can't be opened. "3.Category" (without the space) works.
@Mark-H Seems like @halftrainedharry has likely identified the bug, but just as a bit of housekeeping I don't have FileSluggy installed and disabled upload_translit, the bug still persists.
@halftrainedharry Yes, you're right, this is the error behavior I'm experiencing. 3.Category can be created and works as expected.
Guys, to my mind we should not be supporting spaces in file paths, just as we do not in URL aliases. Yes, it can work when URL encoded, but it's highly problematic and prone to failure. Can we consider discouraging spaces by either issuing an error in the UI when a path has space or automatically replacing spaces with dashes?