Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #2277 (closed defect: untested)

Opened 4 years ago

Last modified 2 years ago

CGI Extension (raw_post_data_fix.rb) fails with Macromedia Flash 8 file uploader

Reported by: mazdak@exinos.com Assigned to: Jeremy Kemper <rails@bitsweat.net>
Priority: low Milestone: 1.x
Component: ActionPack Version: 0.13.1
Severity: normal Keywords: flash upload cgi
Cc:

Description

Flash 8 Player on Windows sends a POST request with CONTENT_LENGTH = 0 if the file you are uploading using the new Flash 8 FileReference mechanism is greater than 10K. Rails fails (correctly), but this causes the next request to also crash and we never get the file uploaded by flash.

There is a simple fix for this:

Just add the following line to if statement that appears on line 5 or 6 of actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb

&& (Integer(env_table['CONTENT_LENGTH']) > 0)

So, the OLD version is:

if boundary = multipart_form_boundary
    @multipart = true
    @params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
else...

the NEW version is:

if boundary = multipart_form_boundary && (Integer(env_table['CONTENT_LENGTH']) > 0)
    @multipart = true
    @params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
else...

In the latest trunk code, the new code becomes:

if method == :post && (boundary = multipart_form_boundary) && (Integer(env_table['CONTENT_LENGTH']) > 0)
    @multipart = true
    @params = read_multipart(boundary, Integer(env_table['CONTENT_LENGTH']))
else...

Attachments

FlashFixes.zip (10.2 kB) - added by mazdak@exinos.com on 11/04/05 12:41:59.
Rails 1.0 Plugin to take care of this problem
flash_upload_request_fix.tbz (1.5 kB) - added by caio on 01/24/08 04:11:36.
plugin for rails 2.0

Change History

11/04/05 12:41:59 changed by mazdak@exinos.com

  • attachment FlashFixes.zip added.

Rails 1.0 Plugin to take care of this problem

11/14/05 06:43:55 changed by bitsweat

  • cc set to rails@bitsweat.net.
  • milestone changed from 1.0 to 1.x.

Hey, it'd be great to see this fixed. Do you have a test case for this behavior?

11/14/05 10:27:03 changed by anonymous

We are using this fix in our live product... So I know it works. The rails 1.0 plugin that I had attached to this should do the trick.

11/14/05 19:01:44 changed by bitsweat

  • cc deleted.
  • owner changed from David to Jeremy Kemper <rails@bitsweat.net>.
  • priority changed from high to low.

That's great news, but we can't include it in Rails without unit tests to ensure that future changes do not break the fix. I'll put it in my queue if you aren't interested in pursuing it. Thanks!

11/15/05 18:10:12 changed by anonymous

We'll try to make some unit tests for it... althoug the standard upload unit tests (if there are any) should work flawlessy with this, which is unit test enough for it (I think).

11/26/06 05:52:57 changed by bitsweat

  • status changed from new to closed.
  • resolution set to untested.

11/26/06 05:53:07 changed by bitsweat

  • component changed from ActiveRecord to ActionPack.
  • milestone changed from 1.2 to 1.x.

01/24/08 04:11:36 changed by caio

  • attachment flash_upload_request_fix.tbz added.

plugin for rails 2.0

01/24/08 04:13:40 changed by caio

For people still dealing with flash 8 for windows, I've made an updated plugin for rails 2.0.

This plugin works entirely differently from previous fixes, by fixing the mailformed request on the fly.

I'm not reopening this ticket because, really, the bug is in the flash player, and it's fixed in the lastest flash, so there's no point in checking a workaround into rails.

let flash 8 die.