-
Notifications
You must be signed in to change notification settings - Fork 68
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
Uploading files with Arabic file names and titles are converted to digits #624
Comments
This is intended behavior https://github.com/silverstripe/silverstripe-assets/blob/2/src/FileNameFilter.php#L18
You can override the defaults as follows using yml config: ---
Name: myproject-filenamefilter-reset
---
SilverStripe\Assets\FileNameFilter:
# Reset default replacements so that we do not merge with existing
default_replacements: null
---
Name: myproject-filenamefilter
---
SilverStripe\Assets\FileNameFilter:
default_replacements:
# remove whitespace
/\s/: '-'
# remove duplicate underscores (since `__` is variant separator)
/_{2,}/: '_'
# remove duplicate dashes
/-{2,}/: '-'
# Remove all leading dots, dashes or underscores
/^[-_\.]+/: ''
# remove non-ASCII chars, only allow alphanumeric plus dash, dot, and underscore (disabled)
# /[^-_A-Za-z0-9+.]+/: '' I cannot give any guarantee how this will behave in a production environment, and whether or not it causes any issues |
@GuySartorelli @emteknetnz would you accept a PR that would prevent the title field from taking the modified file name 66b034bf7ca15? If yes can open this issue or create a new one? |
@satrun77 What would that look like? And have you tried using the configuration steve mentioned above? If you have, and it didn't resolve the problem, can you please describe what is stopping that config from resolving this problem for you? |
@GuySartorelli The configuration controls what characters used for the file name transformation. I'm ok with that, I understand why it is there. What I'm asking for is not about the file name but the title field of the File object. Instead of using the new file name for the title, we could use the actual file name for the title. Then the title field would be |
Ahh, that makes sense. So you want the title to reflect the original file name, regardless of what the new file name is. I think that's sensible. I'll reopen this issue and update the title and description. |
Done, and added an acceptance criterion. If you're keen to do a PR I'd be very happy to review it. |
PR #633 |
PR merged. |
Module version(s) affected
2.2.4
Description
When files with Arabic filenames are uploaded into the CMS, for instance
الطالب لعائلتك.docx
then theName
and theTitle
of theFile
record is converted from Arabic characters to digital characters which is an inaccurate representation of the file:How to reproduce
الطالب لعائلتك.docx
.Filename
change fromالطالب لعائلتك.docx
to something which features digital characters, for instance66b034bf7ca15.docx
.The title reflects that changed/sanitised filename, but should ideally reflect the original filename.
Possible Solution
No response
Additional Context
No response
Validations
silverstripe/installer
(with any code examples you've provided)Acceptance Criteria
PRs
The text was updated successfully, but these errors were encountered: