ruby-grape / ruby-grape/grape

Type FIle (Rack::Multipart::UploadedFile) replace all non-English letters in file name with underscores ( _ )

Open
#2,085 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug?
Dominant language
Ruby
Stars
10k
Forks
1.2k
Avg merge
14h 38m
Merged PRs (30d)
92

Description

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:

params do
  requires :file, type: File, allow_blank: false, desc: 'Image'
end

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"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the multipart upload with Rack::Multipart::UploadedFile and the shown params declaration, then trace the File type validation that handles the filename. Confirm whether the filename is being transformed during validation. Done means non-English filename characters are preserved, with coverage for the supplied Cyrillic filename case.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.