Skip to content

Commit

Permalink
FIX: Backwards compatibility with soupy data
Browse files Browse the repository at this point in the history
* Broken quotes needs to be checked before RFC2231 otherwise the filenames are
  not correctly found

* Parsing "files" out of the header was converted to an empty string instead
  instead of nil when the body was empty.

I love working at the #OSL
  • Loading branch information
Franklin Webber and Ian Cordasco authored and sigmavirus24 committed Aug 23, 2014
1 parent f8ba979 commit 3029e64
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rack/multipart/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ def get_current_head_and_filename_and_content_type_and_name_and_body
def get_filename(head)
filename = nil
case head
when BROKEN_QUOTED, BROKEN_UNQUOTED
filename = $1
when RFC2183
params = Hash[head.scan(DISPPARM)]
filename = params['filename']
filename ||= params['filename*']
filename = $1 if filename and filename =~ /^"(.*)"$/
when BROKEN_QUOTED, BROKEN_UNQUOTED
filename = $1
end

return unless filename
Expand Down Expand Up @@ -234,6 +234,8 @@ def get_data(filename, body, content_type, name, head)
# Generic multipart cases, not coming from a form
data = {:type => content_type,
:name => name, :tempfile => body, :head => head}
elsif !filename && data.empty?
return
end

yield data
Expand Down

0 comments on commit 3029e64

Please sign in to comment.