Jump to:

23456 Posts in 18905 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Upload files with non-standard characters as filename (hebrew)

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 2168 Views
  • mewho
    Avatar
    Community Member
    13 Posts

    Upload files with non-standard characters as filename (hebrew) Link to this post

    Hi everyone.
    first let me start by saying that i LOVE silverstripe. i am using it to develop an internal intranet for my company. i have successfully made a right to left theme and have hebrew displaying perfectly except for one thing.

    when i upload files with hebrew names (an absolute necessity) the upload completes successfully, but it strips all he hebrew characters out of the file name. this is a problem because there are many workers here that don't read english. i must be able upload files with hebrew names, and have them display correctly. if anyone has any advice, i would most appreciate it.

    i have already set the collation in the "FILES" table in the db to utf8_unicode_ci (as per several other webapps that had similar problems) but that did not help.
    thanks,
    mewho

    UPDATE: after i upload the file, and all the hebrew characters are stripped out, i can edit the title and filename and then the hebrew will show up. this leads me to believe that there is some form of character validator that is stripping out characters. can anyone tell where i might find this?

  • mewho
    Avatar
    Community Member
    13 Posts

    Re: Upload files with non-standard characters as filename (hebrew) Link to this post

    bump - PLEASE help me.....i must bypass filename validation!!!!!

  • swaiba
    Avatar
    Forum Moderator
    1788 Posts

    Re: Upload files with non-standard characters as filename (hebrew) Link to this post

    sapphire\filesystem\Upload.php

    function load($tmpFile, $folderPath = false)

          // Generate default filename
          $fileName = str_replace(' ', '-',$tmpFile['name']);
          $fileName = ereg_replace('[^A-Za-z0-9+.-]+','',$fileName);
          $fileName = ereg_replace('-+', '-',$fileName);
          $fileName = basename($fileName);

    I'd say it was '$fileName = ereg_replace('[^A-Za-z0-9+.-]+','',$fileName);' causing your issue, you could remove this but I have no idea of implications this would have...

    good luck...

    Barry

  • mewho
    Avatar
    Community Member
    13 Posts

    Re: Upload files with non-standard characters as filename (hebrew) Link to this post

    thanks for the reply. i tried this, and it had no effect...any other suggestions?

  • swaiba
    Avatar
    Forum Moderator
    1788 Posts

    Re: Upload files with non-standard characters as filename (hebrew) Link to this post

    where is the 'file name' that you can see with the problem? is it the name on the disk, the name in the CMS - if so where do you see and then edit this name. Also where are you doing the upload - what steps?

    I simply searched for new File() and then supposed on that - that more info you give the more help you might get

  • mewho
    Avatar
    Community Member
    13 Posts

    Re: Upload files with non-standard characters as filename (hebrew) Link to this post

    ok,
    i am uploading the files via the admin panel files & images under the upload tab
    i select the file(s) to upload, they are word docs with hebrew names e.g. ????7.1.10.doc. the upload completes successfully and under files i have only 7.1.10.doc as the filename - the hebrew was stripped out of the file name. if i then click edit, i can re-add the hebrew part of the name, but it will only show up under title...the filename field will only accept english characters and numbers.

  • mewho
    Avatar
    Community Member
    13 Posts

    Re: Upload files with non-standard characters as filename (hebrew) Link to this post

    1 problem solved...on irc they recommended that i comment out

    $file = ereg_replace('[^A-Za-z0-9+.-]+','',$file);

    line 194 in file folder.php (saphire\filesystem)

    now the filename is showing up perfectly, but the link does not work. there must be some encoding issue because when i link the file to download, the browser is looking for a filename in hebrew(as it should) but the browser wants %d2%d7%d5 etc. can anyone help? i am so close to perfection on this. Everything in the site/database is utf8. i also tried windows-1255 and iso-8859-8 with no change

    Update:
    ok, after much digging, i believe this is a urldecode problem with tinymce. i am looking at line 93 of htmleditorfield.php

       $candidateFile = File::find(Convert::raw2sql(urldecode($href)));

    but i don't really know what to do with this. i found a site

    http://www.string-functions.com/urldecode.aspx

    that when i plug in the encoded string:

    %d7%92%d7%9c%d7%99%d7%95%d7%9f-%d7%9e%d7%99%d7%93%d7%a2-%d7%a2%d7%9c-%d7%a1%d7%99%d7%9b%d7%95%d7%a0%d7%99%d7%9d-%d7%aa%d7%a2%d7%a1%d7%95%d7%a7%d7%aa%d7%99%d7%9d-%d7%97%d7%a9%d7%9e%d7%9c%d7%90%d7%99-%d7%91%d7%a0%d7%99%d7%99%d7%9f-2.09.doc

    it returns me the correct file name. tinymce is apparently encoding the link "incorrectly" i hope this is clear and someone can help. thanks

    2168 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.