Regression of CGI.parse

xibbar e$B$5$se(B
e$B1sF#$G$9!#e(B

r19613 e$B$G!“L58z$Je(B QUERY_STRING
e$B$r<u$1<h$C$?;~$N=hM}$,2C$o$j$^$7$?$,e(B
([ruby-dev:36618]) e$B!”$3$N1F6A$G0J2<$NF0:n$,JQ$o$C$F$$$^$9!#e(B

$ ./ruby -v -rcgi -e ‘p CGI.parse(“one=a&two=b&two=c&three”)’
ruby 1.9.2dev (2010-01-27 trunk 26441) [i686-linux]
{“one”=>[“a”], “two”=>[“b”, “c”], “three”=>[]}

$ ruby18 -v -rcgi -e ‘p CGI.parse(“one=a&two=b&two=c&three”)’
ruby 1.8.8dev (2010-01-26 revision 26430) [i686-linux]
{“three”=>[nil], “two”=>[“b”, “c”], “one”=>[“a”]}

e$B$D$^$j!"e(Bvalue e$B$N$J$$%-!<$NCM$,e(B [nil] e$B$+$ie(B []
e$B$K$J$j$^$7$?!#$3$NJQ99e(B
e$B<+BN$r0U?^$7$?;EMMJQ99$G$O$J$$$H;W$C$?$N$GJs9p$7$^$9!#e(B

e$B$^$"$I$C$A$NF0:n$G$b$$$$$H$O;W$&$N$G$9$,!"$I$C$A$G$b$$$$$J$i;EMMJQ99e(B
e$B$7$J$$J}$,$$$$$+$J$H;W$$$^$9!#e(Brubyspec
e$B$b<:GT$7$F$$$k$3$H$G$9$7!#e(B
e$B$G$9$,e(B 1.9.1
e$B$K$OF~$C$F$7$^$C$F$$$k$N$G!"$b$7$3$l$G9T$/[email protected]$&$3$H$J$ie(B
rubyspec e$BB&[email protected]$r$*4j$$$7$h$&$H;W$$$^$9!#e(B

diff --git a/lib/cgi/core.rb b/lib/cgi/core.rb
index 3930663…85f4761 100644
— a/lib/cgi/core.rb
+++ b/lib/cgi/core.rb
@@ -337,11 +337,7 @@ class CGI
params = {}
query.split(/[&;]/).each do |pairs|
key, value = pairs.split(’=’,2).collect{|v| CGI::unescape(v) }

  •  if key && value
    
  •    params.has_key?(key) ? params[key].push(value) : params[key] = 
    

[value]

  •  elsif key
    
  •    params[key]=[]
    
  •  end
    
  •  params.has_key?(key) ? params[key].push(value) : params[key] =
    

[value] if key
end
params.default=[].freeze
params
@@ -497,7 +493,7 @@ class CGI
if body.original_filename.empty?
value=body.read.dup.force_encoding(@accept_charset)
(params[name] ||= []) << value

  •      unless value.valid_encoding?
    
  •      if value && !value.valid_encoding?
           if @accept_charset_error_block
             @accept_charset_error_block.call(name,value)
           else
    

@@ -606,7 +602,7 @@ class CGI
unless Encoding.find(@accept_charset) == Encoding::ASCII_8BIT
@params.each do |key,values|
values.each do |value|

  •          unless value.valid_encoding?
    
  •         if value && !value.valid_encoding?
               if @accept_charset_error_block
                 @accept_charset_error_block.call(key,value)

xibbare$B$3$HF#2,$G$9!#e(B

{“three”=>[nil], “two”=>[“b”, “c”], “one”=>[“a”]}

e$B$D$^$j!"e(Bvalue e$B$N$J$$%-!<$NCM$,e(B [nil] e$B$+$ie(B [] e$B$K$J$j$^$7$?!#$3$NJQ99e(B
e$B<+BN$r0U?^$7$?;EMMJQ99$G$O$J$$$H;W$C$?$N$GJs9p$7$^$9!#e(B

e$B$^$"$I$C$A$NF0:n$G$b$$$$$H$O;W$&$N$G$9$,!"$I$C$A$G$b$$$$$J$i;EMMJQ99e(B
e$B$7$J$$J}$,$$$$$+$J$H;W$$$^$9!#e(Brubyspec e$B$b<:GT$7$F$$$k$3$H$G$9$7!#e(B
e$B$G$9$,e(B 1.9.1 e$B$K$OF~$C$F$7$^$C$F$$$k$N$G!"$b$7$3$l$G9T$/[email protected]$&$3$H$J$ie(B
rubyspec e$BB&[email protected]$r$*4j$$$7$h$&$H;W$$$^$9!#e(B

e$B$3$l$Oe(B[nil]e$B$rJV$9J}$,$*[email protected]$m$&$H;W$$$^$7$?!#e(B
e$BMWAG$,[email protected]$+$ie(B[]e$B$rJV$7$?J}$,4r$7$$$O$:$G$9!#e(B

e$B$H$$$&$o$1$G!";EMMJQ99$G$9!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs