-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
File upload: Take ASCII conversion rules of current language and/or user language into account #4972
Comments
I would think that the current user language has the higher chances to match the language of uploaded file names. |
Thinking about it again, I think you are right. The content language does not make much sense as the filenames are independent from the language. I.e. if you upload a file while the content language is set to language A, the filename will be exactly the same once you switch to language B. So we can only rely on the user language here. |
I would think this is the line where we would need to add the change: https://github.com/getkirby/kirby/blob/main/src/Cms/FileActions.php#L183 However, I am wondering whether it would make sense to use |
Something like this for // temporarily store language rules
$rules = Str::$language;
$kirby = App::instance(null, true);
// if current user with language, use those rules for `Str` class
if ($language = $kirby?->language($kirby?->translation()->code())) {
Str::$language = $language->rules();
}
// sanitize name
$name = F::safeName($name);
// reset language rules
Str::$language = $rules;
return $name; |
Sounds about right. I think we should also harmonize the logic of |
Harmonizing methods: #5760 |
For the second part, we need to look into here: Line 228 in d14bc47
… and then pass the custom language slug rules to the |
Description
Kirby only uses the default conversion rules when converting filenames on upload. This breaks when files with names in another language are uploaded.
Expected behavior
Kirby should take the current language into account. We need to determine whether this should be the current content language, the current user language or both.
To reproduce
日本語.pdf
Additional context
getkirby/getkirby.com#1817
The text was updated successfully, but these errors were encountered: