Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with special characters in filename #1185

Closed
gdurelle opened this issue Aug 5, 2013 · 1 comment
Closed

Problem with special characters in filename #1185

gdurelle opened this issue Aug 5, 2013 · 1 comment

Comments

@gdurelle
Copy link
Contributor

gdurelle commented Aug 5, 2013

Hi,
When i do upload a file, i need to match the filename on some other string datas, but i got an error when using special caracters..

params received:

Parameters: {"name"=>"Mylène.png", "_cardbiz_session"=>"be1d5b7a2f27c7c4979ac4c16fe8fc82", "authenticity_token"=>"9vmJ02DjgKYCpoBNUcWwUlpxDXA8ddcoALHXyT6wrnM=", "asset"=>{"file"=># < ActionDispatch::Http::UploadedFile:0x007f94d38d37d0 @original_filename="Mylène.png", @content_type="image/png", @headers="Content-Disposition: form-data; name="asset[file]"; filename="Myle\xCC\x80ne.png"\r\nContent-Type: image/png\r\n", @tempfile=# < File:/var/folders/q5/yvy_v9bn5wl_s5ccy_35qsmw0000gn/T/RackMultipart20130805-51100-1eh07dp > >}, "id"=>"copie-de-sm"}

I log this:

 * logger.debug file_name
 * logger.debug file_name.chars.map(&:to_s).inspect

Each time, same result:

* Mylène
   ["M", "y", "l", "e", "̀", "n", "e"]

* Loïc 
  ["L", "o", "i", "̈", "c"]

Thus my filename comparison fails and throw a weird error:

TypeError (no _dump_data is defined for class Binding)

I checked the encodings with loggers, utf-8 all the time.
working under ruby 1.9.3, rails 3.2.14. Added #encoding: utf-8 in top of any file involved.

If you have any idea of what it could be...

@gdurelle
Copy link
Contributor Author

gdurelle commented Aug 6, 2013

Seems to be linked to MACOSX.

https://www.ruby-forum.com/topic/4407424 refers to https://bugs.ruby-lang.org/issues/7267 MACOSX decomposing special characters into utf8-mac instead of utf-8...
while you can't know the encoding of a file name, just presupose it.

Thanks to our Linux guy where it works properly (because he has a real OS). :)

@gdurelle gdurelle closed this as completed Aug 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant