Ticket #107 (closed defect)

Opened 2 years ago

Last modified 21 months ago

Problem on file uploads

Reported by: brmichel Owned by: why
Priority: major Milestone: Camping 1.6
Component: camping.rb Version: 1.5
Keywords: Cc:

Description

In some (bad) cases, uploading a file can failed. In Base#initialize near the line 400 of camping-unabridged.rb, the uploaded file is read by block of 16384 bytes:

          while l=@in.read(16384)
            if l=~b
              o<<$`.chomp
              @in.seek(-$'.size,IO::SEEK_CUR)
              break
            end
            o<<l
          end 

b is a regexp for detecting the boundary. But if the boundary is splitted on 2 blocks, the regexp doesn't match it.

I have this problem while uploading a file of 65516 bytes, with an HTML form data after it. The HTML form data doesn't appear in @input, but the temporary file created by camping contains the uploaded file and the HTML data.

Attachments

camping-fix-upload.diff (1.8 kB) - added by brmichel 2 years ago.
My patch
camping-fix-upload-2.diff (1.7 kB) - added by evanweaver 22 months ago.
Generalized paths

Change History

Changed 2 years ago by why

  • owner changed from somebody to why
  • status changed from new to assigned

Okay, good, you're right. Just needs a slight change in that loop to keep around the last line.

Changed 2 years ago by zimbatm

I don't know if the CGI lib supports file upload but I was thinking... why not use the ruby cgi lib so that we can remove a few more lines in Camping ?

Changed 2 years ago by why

Because all of this compact parsing and sorting is part of the Camping miracle. I also really dislike cgi.rb.

Changed 2 years ago by brmichel

My patch

Changed 2 years ago by brmichel

I have tested the attached patch, and it works.

Changed 22 months ago by evanweaver

Attaching vaguely altered patch with generalized paths, so that people can apply it directly to gems.

Changed 22 months ago by evanweaver

Generalized paths

Changed 21 months ago by why

  • status changed from assigned to closed

Okay! Applied! Thanks friendly folks.

Note: See TracTickets for help on using tickets.