Bug #8103

Fix for URI.decode_www_form ArgumentError

Added by Trent Ogren over 2 years ago. Updated over 2 years ago.

[ruby-core:53475]
Status:Closed
Priority:Normal
Assignee:akira yamada
ruby -v:ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.1] Backport:

Description

URI.decode_www_form pukes out an ArgumentError if passed any parameter names that aren't followed by an equals sign. Because of this it can't decode some of the strings that were encoded with URI.encode_www_form:

irb> require 'uri'
=> true
irb> querystring = URI.encode_www_form 'a' => '1', 'b' => nil
=> "a=1&b"
irb> URI.decode_www_form querystring
ArgumentError: invalid data of application/x-www-form-urlencoded (a=1&b)
from /Users/misfo/.rbenv/versions/2.0.0-p0/lib/ruby/2.0.0/uri/common.rb:975:in decode_www_form'
from (irb):3
from /Users/misfo/.rbenv/versions/2.0.0-p0/bin/irb:12:in
'

I've attached a patch

uri-decode-www-form-ArgumentError-fix.patch Magnifier (2.01 KB) Trent Ogren, 03/16/2013 10:20 AM

Associated revisions

Revision 40460
Added by Yui NARUSE over 2 years ago

  • lib/uri/common.rb (URI.decode_www_form): follow current URL Standard.
    It gets encoding argument to specify the character encoding.
    It now allows loose percent encoded strings, but denies ;-separator.
    [Bug #8103]

  • lib/uri/common.rb (URI.decode_www_form): follow current URL Standard.
    It gets encoding argument to convert before percent encode.
    Now UTF-16 strings aren't converted to UTF-8 before percent encode
    by default.

Revision 40460
Added by Yui NARUSE over 2 years ago

  • lib/uri/common.rb (URI.decode_www_form): follow current URL Standard.
    It gets encoding argument to specify the character encoding.
    It now allows loose percent encoded strings, but denies ;-separator.
    [Bug #8103]

  • lib/uri/common.rb (URI.decode_www_form): follow current URL Standard.
    It gets encoding argument to convert before percent encode.
    Now UTF-16 strings aren't converted to UTF-8 before percent encode
    by default.

History

#1 Updated by Charlie Somerville over 2 years ago

  • Assignee set to akira yamada

#2 Updated by Yui NARUSE over 2 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r40460.
Trent, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/uri/common.rb (URI.decode_www_form): follow current URL Standard.
    It gets encoding argument to specify the character encoding.
    It now allows loose percent encoded strings, but denies ;-separator.
    [Bug #8103]

  • lib/uri/common.rb (URI.decode_www_form): follow current URL Standard.
    It gets encoding argument to convert before percent encode.
    Now UTF-16 strings aren't converted to UTF-8 before percent encode
    by default.

Also available in: Atom PDF