Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ActionDispatch::Http:Parameters force encoding of all params but filename of an uploaded file #869

Closed
lighthouse-import opened this Issue · 3 comments

5 participants

@lighthouse-import

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6470
Created by Franck - 2011-02-25 15:37:10 UTC

I run into a problem when I submit a form with a text field and a filename of an uploaded file both containing special chars.

Tracking down the issue it seems that while ActionDispatch force the encoding of all string paramaters to UTF-8 (see ActionDispatch::Http:Parameters encode_params private method), it does not do at to the filename of the uploaded file.

params is then filled with two different encoding (UTF-8 and ASCII-8BIT) causing an Encoding::CompatibilityError later on Arel-2.0.8 (to_sql.rb visit_Arel_Nodes_Values method).

I monkey patched ActionDispatch::Http:UploadedFile like so and it works :

  def initialize(hash)
    @original_filename = hash[:filename].force_encoding("UTF-8")        
    @content_type      = hash[:type]
    @headers           = hash[:head]
    @tempfile          = hash[:tempfile]
    raise(ArgumentError, ':tempfile is required') unless @tempfile
  end

My computing skill stop here. I let you guys decide if this is a bug or if I'm doing something wrong.

@lighthouse-import

Imported from Lighthouse.
Comment by Jim Sagevid - 2011-04-27 09:09:04 UTC

+1

@bayja

why is this issue closed? is there a better way to deal with this matter?
i'm still monkey patching the code to bypass this problem.

@pixeltrix pixeltrix reopened this
@pixeltrix pixeltrix was assigned
@dmathieu dmathieu referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@thoefer

+1

@josevalim josevalim closed this in 383d56b
@josevalim josevalim closed this in deff597
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.