Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6324155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:39:06+00:00 2026-05-24T16:39:06+00:00

My setup: Rails 3.0.9, Ruby 1.9.2 Due to a bug in Rack 1.2.3, I’m

  • 0

My setup: Rails 3.0.9, Ruby 1.9.2

Due to a bug in Rack 1.2.3, I’m attempting to override Rack::Utils::Multipart.parse_multipart by creating a new file

rack_parse_multipart.rb

module Rack
  module Utils
    module Multipart
      def self.parse_multipart(env)
        ...my changes...           
      end
    end
 end    
end

Now I just need to figure out where I require this file, can someone point me in the right direction? Thanks in advance for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T16:39:07+00:00Added an answer on May 24, 2026 at 4:39 pm

    For others having problems with this Rack 1.2.3 bug, there is a nice copy-paste solution here https://github.com/rack/rack/issues/186

    goes in config/initializers

    # -*- encoding: binary -*-
    require 'rack/utils'
    module Rack
      module Utils
        module Multipart
          def self.parse_multipart(env)
            unless env['CONTENT_TYPE'] =~
                %r|\Amultipart/.*boundary=\"?([^\";,]+)\"?|n
              nil
            else
              boundary = "--#{$1}"
    
              params = {}
              buf = ""
              content_length = env['CONTENT_LENGTH'].to_i
              input = env['rack.input']
              input.rewind
    
              boundary_size = Utils.bytesize(boundary) + EOL.size
              bufsize = 16384
    
              content_length -= boundary_size
    
              read_buffer = ''
    
              status = input.read(boundary_size, read_buffer)
              raise EOFError, "bad content body"  unless status == boundary + EOL
    
              rx = /(?:#{EOL})?#{Regexp.quote boundary}(#{EOL}|--)/n
    
              loop {
                head = nil
                body = ''
                filename = content_type = name = nil
    
                until head && buf =~ rx
                  if !head && i = buf.index(EOL+EOL)
                    head = buf.slice!(0, i+2) # First \r\n
                    buf.slice!(0, 2)          # Second \r\n
    
                    token = /[^\s()<>,;:\\"\/\[\]?=]+/
                    condisp = /Content-Disposition:\s*#{token}\s*/i
                    dispparm = /;\s*(#{token})=("(?:\\"|[^"])*"|#{token})*/
    
                    rfc2183 = /^#{condisp}(#{dispparm})+$/i
                    broken_quoted = /^#{condisp}.*;\sfilename="(.*?)"(?:\s*$|\s*;\s*#{token}=)/i
                    broken_unquoted = /^#{condisp}.*;\sfilename=(#{token})/i
    
                    if head =~ rfc2183
                      filename = Hash[head.scan(dispparm)]['filename']
                      filename = $1 if filename and filename =~ /^"(.*)"$/
                    elsif head =~ broken_quoted
                      filename = $1
                    elsif head =~ broken_unquoted
                      filename = $1
                    end
    
                    if filename && filename !~ /\\[^\\"]/
                      filename = Utils.unescape(filename).gsub(/\\(.)/, '\1')
                    end
    
                    content_type = head[/Content-Type: (.*)#{EOL}/ni, 1]
                    name = head[/Content-Disposition:.*\s+name="?([^\";]*)"?/ni, 1] || head[/Content-ID:\s*([^#{EOL}]*)/ni, 1]
    
                    if filename
                      body = Tempfile.new("RackMultipart")
                      body.binmode  if body.respond_to?(:binmode)
                    end
    
                    next
                  end
    
                  # Save the read body part.
                  if head && (boundary_size+4 < buf.size)
                    body << buf.slice!(0, buf.size - (boundary_size+4))
                  end
    
                  c = input.read(bufsize < content_length ? bufsize : content_length, read_buffer)
                  raise EOFError, "bad content body"  if c.nil? || c.empty?
                  buf << c
                  content_length -= c.size
                end
    
                # Save the rest.
                if i = buf.index(rx)
                  body << buf.slice!(0, i)
                  buf.slice!(0, boundary_size+2)
    
                  content_length = -1  if $1 == "--"
                end
    
                if filename == ""
                  # filename is blank which means no file has been selected
                  data = nil
                elsif filename
                  body.rewind
    
                  # Take the basename of the upload's original filename.
                  # This handles the full Windows paths given by Internet Explorer
                  # (and perhaps other broken user agents) without affecting
                  # those which give the lone filename.
                  filename = filename.split(/[\/\\]/).last
    
                  data = {:filename => filename, :type => content_type,
                          :name => name, :tempfile => body, :head => head}
                # elsif !filename && content_type
                #   body.rewind
                # 
                #   # Generic multipart cases, not coming from a form
                #   data = {:type => content_type,
                #           :name => name, :tempfile => body, :head => head}
                else
                  data = body
                end
    
                Utils.normalize_params(params, name, data) unless data.nil?
    
                # 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
              }
    
              input.rewind
    
              params
            end
          end
        end
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get Ruby on Rails setup on my new eeeubuntu install and
I'm attempting to setup Ruby on Rails on IIS7. I've been reading lots of
I've been trying to get setup with Ruby on Rails today, but I think
I've set up a new Rails 2.3.2 app and added the Basecamp API ruby
I have a simple model setup in my Ruby on Rails app. (User {name,
Hey guys I have a ruby on rails app with a before filter setup
I am creating a site in Ruby on Rails, I have two models a
My setup: Rails 3.0.9, Ruby 1.9.2 I am using Cancan to authorize a controller
I'm creating a Ruby on Rails app that consists of stories. Each story has
My setup: Rails 2.3.10, Ruby 1.8.7 This is a simple question but I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.