? ? ? Pending

User tests: Successful: Unsuccessful:

avatar PhilETaylor
PhilETaylor
30 Apr 2021

Fixes #33452

Summary of Changes

If all that is left after making the file name safe is the extension, then error and say why.

Also fixes a double slash issue // when a filename has been made save.

Testing Instructions

WIHTOUT iconv and intl PHP extensions, attempt to rename a FILE to МИ.png

Actual result BEFORE applying this Pull Request

Screenshot 2021-04-30 at 23 13 11

and the moved file is created at /images/png

Expected result AFTER applying this Pull Request

Screenshot 2021-04-30 at 23 12 35

Documentation Changes Required

avatar PhilETaylor PhilETaylor - open - 30 Apr 2021
avatar PhilETaylor PhilETaylor - change - 30 Apr 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 30 Apr 2021
Category Administration Language & Strings Front End Plugins
avatar Kostelano Kostelano - test_item - 1 May 2021 - Tested successfully
avatar Kostelano
Kostelano - comment - 1 May 2021

I have tested this item successfully on 6dd7e1c

Thank you!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33454.

Screenshot_1

avatar Fedik
Fedik - comment - 1 May 2021

ideally it should be transliterated, but an exception also enough for quick fix :)

avatar PhilETaylor
PhilETaylor - comment - 1 May 2021

It can't be if you are missing the PHP extensions to actually do that!

avatar Fedik
Fedik - comment - 1 May 2021

It can't be if you are missing the PHP extensions to actually do that!

It is still possible, we actually doing it for an alias field,
However it does not cover everything, mostly only for installed languages that provide transliteration in their localise.php

// Transliterate on the language requested (fallback to current language if not specified)
$lang = $language == '' || $language == '*' ? Factory::getLanguage() : Language::getInstance($language);
$str = $lang->transliterate($str);

and

if ($this->transliterator !== null)
{
return \call_user_func($this->transliterator, $string);
}

upd, example for uk-UA localise.php:
https://github.com/Joomla-Ukraine/uk-UA/blob/88ca9b96a3872de4e4971315d24465ee9b78b5e0/uk-UA_3.x/language/uk-UA/uk-UA.localise.php#L100-L109

avatar infograf768
infograf768 - comment - 1 May 2021

for j4, the priority for the alias as well as for upload image, is:

1 intl extension
2 language pack custom transliteration.
3 for alias only, if no ascii, the date of saving

avatar PhilETaylor PhilETaylor - change - 1 May 2021
Labels Added: ? ?
avatar PhilETaylor
PhilETaylor - comment - 1 May 2021

Well if that case the CMS should be cleaning up the file name before asking the File library to write the file.

The CMS File library is not the place to be injecting lots of language specific code.

File::makeSafe is not the place for language pack transliteration.

Replacing a failed makeSafe with todays date would be worse in my opinion - someone attempting to rename a file, only for that file to not be renamed to what they asked, but to a date... is likely to confuse.

avatar Fedik
Fedik - comment - 1 May 2021

File::makeSafe is not the place for language pack transliteration.

Correct.

Here we have LocalAdapter::getSafeName().

*/
private function getSafeName(string $name): string
{

Additionally, the same issue may affect all methods in LocalAdapter, not only move():

createFolder()
createFile()
copy()

Maybe you better move an exception in to LocalAdapter::getSafeName() method,
Ideally add transliteration there also :)

avatar PhilETaylor
PhilETaylor - comment - 1 May 2021

$lang->transliterate('МИМИМИМИ') also returns a blank string...

avatar PhilETaylor
PhilETaylor - comment - 1 May 2021

I have added the exceptions in the LocalAdapter makeSafe, and added language transliterate with another check as both File::makeSafe and $lang->transliterate('МИМИМИМИ') can return a blank string.

avatar richard67
richard67 - comment - 2 May 2021

I've updated the branch to latest 4.0-dev to get rid of the unrelated javascript-cs error in drone.

@Kostelano Could you redo your test? The PR has meanwhile received some change beside that branch update. Thanks in advance.

avatar Kostelano
Kostelano - comment - 3 May 2021

So, it works a little differently than I expect.

I just take a file with a Latin name and try to ADD Russian letters to its name. I receive an error NOT declared in the PR, but already another one.

Screenshot_1

If I try to rename the file to a Russian name WITHOUT a combination with Latin names, I will already get the declared error.

Screenshot_2

It seems to me that both cases should somehow correspond to the same error.

Also, note that errors are duplicated on the same page, similar to the error reported at #33450.

avatar PhilETaylor
PhilETaylor - comment - 3 May 2021

If a file exists with just the latin chars, then that is correct, as makeSafe will remove the russian and leave the other chars (if your server doesn't have iconv/intl installed)

avatar Fedik Fedik - test_item - 3 May 2021 - Tested successfully
avatar Fedik
Fedik - comment - 3 May 2021

I have tested this item successfully on cee7960


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33454.

avatar Kostelano Kostelano - test_item - 5 May 2021 - Tested successfully
avatar Kostelano
Kostelano - comment - 5 May 2021

I have tested this item successfully on cee7960

Ok, the main issue is solved by this PR. Thank you!


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33454.

avatar alikon alikon - change - 5 May 2021
Status Pending Ready to Commit
avatar alikon
alikon - comment - 5 May 2021

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33454.

avatar wilsonge wilsonge - change - 6 May 2021
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-05-06 09:48:25
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 6 May 2021
avatar wilsonge wilsonge - merge - 6 May 2021
avatar wilsonge
wilsonge - comment - 6 May 2021

Thanks!

Add a Comment

Login with GitHub to post a comment