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

[3.x] File extension drops in media manager when friendly url pattern restricts dot #16551

Open
dimasites opened this issue Mar 28, 2024 · 3 comments
Labels
bug The issue in the code or project, which should be addressed.

Comments

@dimasites
Copy link
Contributor

dimasites commented Mar 28, 2024

Bug report

Summary

I want to restrict dot in resource aliases, but related setting affects uploaded files.

Step to reproduce

On fresh modx installed, add . to friendly_alias_restrict_chars_pattern system setting default value (for exclude dot in resource aliases in my case)
Setting value become to /[\0\x0B\t\n\r\f\a&=+%#<>"~:`@\?\[\]\{\}\|\^'\\.]/

Then try to upload file with name te st.txt via media manager.

Observed behavior

After upload, you get te-sttxt (without dot before .txt extension)

If i disable upload_translit setiing, file name become to te st.txt → unsafe, non-friendly-url compatible an poor looking. May contain special chars and etc.

Expected behavior

Dots in file extensions (and other dots may be via special pattern) preserved when upload or remane file via media manager.

It will be great to set up RegExp pattenrs for uploaded file names and for fliendly URLs separately!

Environment

MODX 3.0.4. upload_translit setiing activated (by default) and friendly_alias_restrict_chars = pattern (by default)

@dimasites dimasites added the bug The issue in the code or project, which should be addressed. label Mar 28, 2024
@dimasites dimasites changed the title [3.x] File extension drops upload_translit when friendly url pattern restricts dot [3.x] File extension drops in media manager when friendly url pattern restricts dot Mar 28, 2024
@denius-dev
Copy link

+1

1 similar comment
@vasilueff
Copy link

+1

@pbowyer
Copy link
Contributor

pbowyer commented Apr 14, 2024

In other systems, I remove the file extension, sanitize the file name, and then append an extension based on the file's Mime type. I do this because the extension isn't always right; sometimes for innocent reasons (a PNG with a .jpg extension) and other times to circumvent restrictions.

Either a separate system setting for each regex or removing the file extension/appending a new file extension after sanitization would avoid this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue in the code or project, which should be addressed.
Projects
None yet
Development

No branches or pull requests

4 participants