Skip to content

Commit

Permalink
don't set @content_length to a magic value
Browse files Browse the repository at this point in the history
Let just use a local boolean to determine whether or not the parser
should leave the loop
  • Loading branch information
tenderlove committed Aug 27, 2015
1 parent 896471f commit dd8afc9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/rack/multipart/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ def parse
end
end

should_break = false
# Save the rest.
if i = @buf.index(rx)
body << @buf.slice!(0, i)
@buf.slice!(0, @boundary_size+2)

@content_length = -1 if $1 == "--"
should_break = true if $1 == "--"
end

get_data(filename, body, content_type, name, head) do |data|
Expand All @@ -80,7 +81,7 @@ def parse
end

# break if we're at the end of a buffer, but not if it is the end of a field
break if (@buf.empty? && $1 != EOL) || @content_length == -1
break if (@buf.empty? && $1 != EOL) || should_break
end

@env[RACK_TEMPFILES] = opened_files
Expand Down

0 comments on commit dd8afc9

Please sign in to comment.