• Resolved okiwan

    (@okiwan)


    Dear NextGen team,

    First of all, I must say that this is an old issue (posts go back to two or three years) which so far has not been solved: I have been unable to find a solution, nor the problem has been fixed on further versions of the product.

    The problem comes when you want to upload images which filename has non-ASCII characters (for instance, with accent marks in spanish but this could be extended to any other non-english language).

    What is happening now is that, when uploading an image with that kind of filename, let’s say samplé 3.jpg, the class GalleryStorage_Driver_Base performs a filename sanitation using WordPress sanitize_title_with_dashes resulting sampl%c3%a9-3.jpg. In my opinion this was a quick way to solve sanitation but should not be used because, apart from changing white spaces into dashes, it also codifies as an URL the string if non-ASCII characters are found.
    On that moment an entry has already been added to the database with the URL encoded filename and a file is created on the server with the URL encoded name. So far, the file is saved. The problem comes when you want to retrieve the file: you put the URL generated on the browser (or just explore the gallery) and when accessing the server the request is sent to the server…then the server detects that the URL has codified elements, decodify them and try to access the file system…ops, file not found!

    A quick workaround would be:

    Class   : GalleryStorage_Driver_Base.php
    Function: upload_base64_image
    
    Original line:
    $filename = $filename ? sanitize_title_with_dashes($filename) : uniqid('nextgen-gallery');
    
    New line:
    $filename = $filename ? urldecode(sanitize_title_with_dashes($filename)) : uniqid('nextgen-gallery');

    With the change, the file will be saved with the correct name (original characters) and even using the URL encoded string will make it accessible. Of course this solves the problem accessing the file, but on the user interface the name of the file is still displaying the encoding and the database entry for that file has also the encoding.

    This would be a nice and quick fix. Please let me know if I can provide you additional info in order to track and finally fix it.

    Thanks,
    Sergio

    https://wordpress.org/plugins/nextgen-gallery/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor photocrati

    (@photocrati)

    @okiwan – We believe to have addressed the issue with “special” characters in the next (beta) release of NextGEN Gallery.

    Please feel free to let us know if it does not correct the issues you are specifically seeing and we will revisit your suggestion to correct the issue as you see it.

    … and thank you very much for sharing your findings and your work-around on this long-standing issue, too!

    – Cais.

    Thread Starter okiwan

    (@okiwan)

    Nice to know, thanks. I will be keep an eye once the version goes to production.

    Best regards,
    Sergio

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filename sanitation for non-ASCII encodings’ is closed to new replies.