Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

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

Upload files with non-standard characters as filename (hebrew)


Reply


7 Posts   2207 Views

Avatar
mewho

Community Member, 13 Posts

16 July 2010 at 12:25am

Edited: 16/07/2010 1:02am

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?

Avatar
mewho

Community Member, 13 Posts

19 July 2010 at 12:46am

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

Avatar
swaiba

Forum Moderator, 1798 Posts

19 July 2010 at 1:34am

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

Avatar
mewho

Community Member, 13 Posts

19 July 2010 at 1:41am

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

Avatar
swaiba

Forum Moderator, 1798 Posts

19 July 2010 at 2:00am

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 :)

Avatar
mewho

Community Member, 13 Posts

19 July 2010 at 2:19am

Edited: 19/07/2010 2:20am

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.

Avatar
mewho

Community Member, 13 Posts

20 July 2010 at 2:15am

Edited: 20/07/2010 2:29am

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