-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Type FIle (Rack::Multipart::UploadedFile) replace all non-English letters in file name with underscores ( _ ) #2085
Comments
Looks suspicious. Can you please try turning this into a spec, @alexgonor ? |
@dblock I'm not quite sure what you want to see, can you clarify the request, please? |
You're saying that Grape file validation is mangling data. I am pretty sure it does not. Write a spec that demonstrates your problem - AFAIK what you're seeing is some kind of encoding issue and maybe Grape is converting unicode characters into some other kind of encoding and that could be a bug. |
Ok, this is simple Rails app with grape, you can send file with non-English letters in file name to PUT localhost:3000/ and in params you will be see something like this: |
I can take a look when I have a chance. To fix the issue faster:
|
@alexgonor I'm having the same issue, have you managed to fix it? |
I figured out what was the reason: it is a combination of Grape + Carriervawe. Curious moment that we can explore on this test. When we use
This is the first part. The second part is actually sanitization performed by Carrierwave. It simply replaces all The only question for me, why behavior is different for different files |
@khataev Do you have a repro of this different behavior in a spec? |
Hello, I'm notice, that grape File type validation replace all non-English letters with an underscore symbol
I send:
------WebKitFormBoundarybo7OclPI12IMowot Content-Disposition: form-data; name="file"; filename="привет-hello.png" Content-Type: image/png
and on endpoint I have next validation:
but in params I see:
{"file"=> {"filename"=>"\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82-hello.png", "type"=>"image/png", "name"=>"file", "tempfile"=>#<File:/tmp/RackMultipart20200710-8-11mcjd3.png>, "head"=>"Content-Disposition: form-data; name=\"file\"; filename=\"\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82-hello.png\"\r\nContent-Type: image/png\r\n"} }
And this "\xD0\xBF\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82-hello.png" it same as "____________-hello.png"
The text was updated successfully, but these errors were encountered: