No Code Attached Yet
avatar PhilETaylor
PhilETaylor
15 Nov 2021

Steps to reproduce the issue

upload an image to your local image folder - using FTP, not Joomla - with accents in the filename

THESE ACCENTS NEED TO NOT BE UTF-8 ENCODED !! This is important.

Then navigate to Admin -> Content -> Media
Note the blank screen where you would expect images/folders to show

Examples (as an example only, DO NOT COPY AND PASTE THESE!):

Filename
07_CALÍOPE_topticket.jpg
Bànner_web.png
còpia.jpg
Dúo.jpg

To create a non-uff-8 accented file - on file systems that allow it (MacOS Doesnt!) - you can use this PHP script:

file_put_contents("/path/to/images/umlaut_\xFC.png",file_get_contents('/path/to/images/joomla_black.png'));

Expected result

Media manager should work correctly, handling the accents correctly, like it does accents that are utf-8

AT A MINIMUM media manager should report an error message if the AJAX response is blank, or contains error messages.

AT BEST being able to convert and display non-uff-8 filenames

Actual result

The API AJAX CALL returns a blank screen and 200 OK response.

This happens because the list of files is provided to a JsonResponse which is case __toString using json_encode with no error handling. When json_encode fails, it returns an empty string.

If json_encode is used with JSON_THROW_ON_ERROR (while debugging) then the real error becomes apparent in the body of the AJAX response which shows Malformed UTF-8 characters error message, but com_media does not look for error messages/Exceptions in the JSON and so doesnt show this error message anyway, and also doesnt show any error message if the response is a blank response body... it just sits there with a moving blue loading indicator forever.

If you var_dump before the json_encode you can see the "malformed" characters (if you view using a UTF-8 encoded browser page)

Screenshot 2021-11-15 at 13 21 16

Additional comments

Yes I could fix this, but its best fixed by someone who uses non-standard encodings and who can replicate and test. This is best done with someone on a linux operating system and not a MacOS.

Please dont tell me you cannot replicate this problem, if you are just copy and pasting accents from the web... in UTF-8 /facepalm.

Seen in the real world twice with German accents written in filenames and files uploaded over FTP - NOT files uploaded by Joomla whose filenames are written by Joomla. Seen also with other (non-joomla) galleries that create the images online, and save them to the file system with non-utf8 filenames.

Want to learn more? see: https://evertpot.com/filesystem-encoding-and-php/

avatar PhilETaylor PhilETaylor - open - 15 Nov 2021
avatar joomla-cms-bot joomla-cms-bot - change - 15 Nov 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 15 Nov 2021
avatar PhilETaylor PhilETaylor - change - 15 Nov 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 Nov 2021
avatar PhilETaylor PhilETaylor - change - 15 Nov 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 Nov 2021
avatar PhilETaylor PhilETaylor - change - 15 Nov 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 Nov 2021
avatar PhilETaylor PhilETaylor - change - 15 Nov 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 Nov 2021
avatar PhilETaylor PhilETaylor - change - 15 Nov 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 Nov 2021
avatar PhilETaylor PhilETaylor - change - 15 Nov 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 Nov 2021
avatar PhilETaylor PhilETaylor - change - 15 Nov 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 Nov 2021
avatar PhilETaylor PhilETaylor - change - 15 Nov 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 Nov 2021
avatar PhilETaylor PhilETaylor - change - 15 Nov 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 Nov 2021
avatar PhilETaylor
PhilETaylor - comment - 16 Nov 2021

Also (kindof) related #36061

avatar PhilETaylor PhilETaylor - change - 7 Mar 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-03-07 18:36:18
Closed_By PhilETaylor
avatar PhilETaylor PhilETaylor - close - 7 Mar 2022

Add a Comment

Login with GitHub to post a comment