cgi.rbのformの挙動

e$BF#2,$G$9!#e(B

cgi.rbe$B$Ge(Bforme$B$Ke(Bmethode$B$^$?$Oe(Benctypee$B$rEO$9$H$-$Ke(B
e$B>.J8;z$G%-!<$rEO$9$He(Bmethode$B$N9`L$,=EJ#$7$^$9!#e(B
e$B$3$l$O%P%0$G$9$h$M!)e(B

$ echo |ruby -rcgi -e puts CGI.new(html3).form(method=>post)

e$B$=$7$F!e(Bgete$B$r>.J8;z$G%-!<$r=q$$$Fe(B"method=>"get"e$B$J$I$HEO$7$?>l9g$K$Oe(B
poste$B$He(Bgete$B$NN>J}$,B8:_$7$F$7$^$$$^$9!#e(B

$ echo |ruby -rcgi -e puts CGI.new(html3).form(method=>get)

e$B%-!<$,BgJ8;z$N>l9g$OBg>fIW$G$9!#e(B

$ echo |ruby -rcgi -e puts CGI.new(html3).form(METHOD=>get)

e$B$H$j$"$($:%Q%C%Ae(B

/usr/lib/ruby/1.8/cgi.rb 2006-08-22 18:38:19.000000000 +0900
+++ cgi.rb 2006-09-26 09:19:24.464384096 +0900
@@ -1542,10 +1542,10 @@
{ METHOD => method, ACTION => action,
ENCTYPE => enctype }
else

  •                 unless method.has_key?("METHOD")
    
  •                 unless method.has_key?("METHOD") ||
    

method.has_key?(metho
d)
method[METHOD] = post
end

  •                 unless method.has_key?("ENCTYPE")
    
  •                 unless method.has_key?("ENCTYPE") ||
    

method.has_key?(enct
ype)
method[ENCTYPE] = enctype
end
method

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message Re: [ruby-dev:29601] cgi.rbe$B$Ne(Bforme$B$N5sF0e(B
on Tue, 26 Sep 2006 09:29:28 +0900, Fujioka [email protected] writes:

|cgi.rbe$B$Ge(Bforme$B$Ke(Bmethode$B$^$?$Oe(Benctypee$B$rEO$9$H$-$Ke(B
|e$B>.J8;z$G%-!<$rEO$9$He(Bmethode$B$N9`L$,=EJ#$7$^$9!#e(B
|e$B$3$l$O%P%0$G$9$h$M!)e(B

e$B$&!<$s!"%I%-%e%a%s%H$K$OBgJ8;z$Ge(BMETHODe$B$de(BENCTYPEe$B$r;XDj$9$k$he(B
e$B$&$K=q$$$F$"$j!"BgJ8;z>.J8;z$rL5;k$9$k$H$O=q$$$F$J$$$o$1$G$9e(B
e$B$+$i!4V0c$$$d$9$$$N$O3N$+$H$7$F$b!%P%0$H$$$&$N$OHyL/$N$h$&e(B
e$B$J!#$I$&$J$s$G$7$g$&$M!#e(B

e$BF#2,$G$9!#e(B

|cgi.rbe$B$Ge(Bforme$B$Ke(Bmethode$B$^$?$Oe(Benctypee$B$rEO$9$H$-$Ke(B
|e$B>.J8;z$G%-!<$rEO$9$He(Bmethode$B$N9`L$,=EJ#$7$^$9!#e(B
|e$B$3$l$O%P%0$G$9$h$M!)e(B

e$B$&!<$s!"%I%-%e%a%s%H$K$OBgJ8;z$Ge(BMETHODe$B$de(BENCTYPEe$B$r;XDj$9$k$he(B
e$B$&$K=q$$$F$"$j!"BgJ8;z>.J8;z$rL5;k$9$k$H$O=q$$$F$J$$$o$1$G$9e(B
e$B$+$i!4V0c$$$d$9$$$N$O3N$+$H$7$F$b!%P%0$H$$$&$N$OHyL/$N$h$&e(B
e$B$J!#$I$&$J$s$G$7$g$&$M!#e(B

e$B3N$+$K%I%-%e%a%s%H$OBgJ8;z$G=q$$$F$"$j$^$9$M!#e(B
e$BBP1~$7$F$"[email protected][email protected]$1$I!"8=>u$O%P%0$G$O$J$$$H$$$&$3$H$G$9$+!#e(B
e$B$[$+$N%-!<[email protected]$H$=$N$^$^M?$($i$l$k$N$G!e(Bmethode$B$He([email protected]$1$,e(B
e$BBgJ8;z$8$c$J$$$H$$$1$J$$$H$$$&$N$O$A$g$C$H$J$!$H;W$$$^$9!#e(B
e$B$$H$OH=CG$O$*G$$;$7$^$9!#e(B

[email protected]$G$9!#e(B

At Tue, 26 Sep 2006 11:15:06 +0900,
Fujioka wrote in [ruby-dev:29603]:

e$BBP1~$7$F$"[email protected][email protected]$1$I!"8=>u$O%P%0$G$O$J$$$H$$$&$3$H$G$9$+!#e(B
e$B$[$+$N%-!<[email protected]$H$=$N$^$^M?$($i$l$k$N$G!"e(Bmethode$B$He([email protected]$1$,e(B
e$BBgJ8;z$8$c$J$$$H$$$1$J$$$H$$$&$N$O$A$g$C$H$J$!$H;W$$$^$9!#e(B

cgi.rbe$BA4BN$H$7$F$_$k$H!"!Ve(Bmethode$B$He([email protected]$1!W$8$c$J$/$Fe(BHashe$B$GEO$7$Fe(B
e$B$$$k$b$N$9$Y$F$G$9$M!#e(B"method"e$B$He(B"Method"e$B$,$"$C$?$i$I$&$9$k$+$H$+9M$($ke(B
e$B$H$a$s$I$&$J$3$H$K$J$j$=$&$J$N$G!"%(%i!<$K$7$F$7$^$&$[$&$,$$$$$h$&$J5$e(B
e$B$b$7$^$9!#e(B

e$B$G$b$$$C$Q$$$"[email protected]$h$J$!!#e(B

e$B$o$?$J$Y$G$9!#e(B

Fujioka [email protected] writes:

$ echo |ruby -rcgi -e puts CGI.new(html3).form(method=>post)

e$B$3$l$re(B1.9e$B$G<B9T$7$F$_$k$He(B

% echo |ruby-1.9 -rcgi -e puts CGI.new(html3).form(method=>post)
<FORM[" METHOD=post", "
ENCTYPE=application/x-www-form-urlencoded", "
method=post"]>

e$B$N$h$&$Ke(BArray#to_se$B$N1F6A$,$b$m$K=P$F$^$9!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message Re: [ruby-dev:29604] Re: cgi.rbe$B$Ne(Bforme$B$N5sF0e(B
on Tue, 26 Sep 2006 12:41:22 +0900, Nobuyoshi N.
[email protected] writes:

|cgi.rbe$BA4BN$H$7$F$_$k$H!"!Ve(Bmethode$B$He([email protected]$1!W$8$c$J$/$Fe(BHashe$B$GEO$7$Fe(B
|e$B$$$k$b$N$9$Y$F$G$9$M!#e(B"method"e$B$He(B"Method"e$B$,$"$C$?$i$I$&$9$k$+$H$+9M$($ke(B
|e$B$H$a$s$I$&$J$3$H$K$J$j$=$&$J$N$G!"%(%i!<$K$7$F$7$^$&$[$&$,$$$$$h$&$J5$e(B
|e$B$b$7$^$9!#e(B

e$B$?$V$se(Battributee$B$K$J$ke([email protected],2=$9$kI,MW$,$e(B
e$B$k$s$G$7$g$&$M!#$$$D$d$k$+$J$!#e(B

[email protected]$G$9!#e(B

At Tue, 26 Sep 2006 12:52:43 +0900,
Yukihiro M. wrote in [ruby-dev:29605]:

|cgi.rbe$BA4BN$H$7$F$_$k$H!"!Ve(Bmethode$B$He([email protected]$1!W$8$c$J$/$Fe(BHashe$B$GEO$7$Fe(B
|e$B$$$k$b$N$9$Y$F$G$9$M!#e(B"method"e$B$He(B"Method"e$B$,$"$C$?$i$I$&$9$k$+$H$+9M$($ke(B
|e$B$H$a$s$I$&$J$3$H$K$J$j$=$&$J$N$G!"%(%i!<$K$7$F$7$^$&$[$&$,$$$$$h$&$J5$e(B
|e$B$b$7$^$9!#e(B

e$B$?$V$se(Battributee$B$K$J$ke([email protected],2=$9$kI,MW$,$e(B
e$B$k$s$G$7$g$&$M!#$$$D$d$k$+$J$!#e(B

cgi.rbe$B$r<N$F$k$H$-e(B?

Index: lib/cgi.rb

RCS file: /pub/cvs/ruby/lib/cgi.rb,v
retrieving revision 1.68.2.18
diff -U 2 -p -u -r1.68.2.18 cgi.rb
lib/cgi.rb 23 Sep 2006 12:47:11 -0000 1.68.2.18
+++ lib/cgi.rb 26 Sep 2006 04:27:21 -0000
@@ -1543,10 +1543,6 @@ class CGI
ENCTYPE => enctype }
else

  •                 unless method.has_key?("METHOD")
    
  •                   method["METHOD"] = "post"
    
  •                 end
    
  •                 unless method.has_key?("ENCTYPE")
    
  •                   method["ENCTYPE"] = enctype
    
  •                 end
    
  •                 method["METHOD"] ||= "post"
    
  •                 method["ENCTYPE"] ||= enctype
                    method
                  end
    

@@ -1637,4 +1633,12 @@ class CGI
attributes = { PRETTY => true }
end

  •  canonical = {}
    
  •  attributes.each {|key, value|
    
  •    if old = canonical[upper = key.upcase]
    
  •      raise ArgumentError,
    
  •        "duplcate keys in different cases: #{old} and #{key}"
    
  •    end
    
  •    canonical[upper] = key
    
  •  end
     pretty = attributes.delete("PRETTY")
     pretty = "  " if true == pretty

e$BF#2,$G$9!#e(B

cgi.rbe$BA4BN$H$7$F$_$k$H!"!Ve(Bmethode$B$He([email protected]$1!W$8$c$J$/$Fe(BHashe$B$GEO$7$Fe(B
e$B$$$k$b$N$9$Y$F$G$9$M!#e(B"method"e$B$He(B"Method"e$B$,$"$C$?$i$I$&$9$k$+$H$+9M$($ke(B
e$B$H$a$s$I$&$J$3$H$K$J$j$=$&$J$N$G!"%(%i!<$K$7$F$7$^$&$[$&$,$$$$$h$&$J5$e(B
e$B$b$7$^$9!#e(B

e$B$G$b$$$C$Q$$$"[email protected]$h$J$!!#e(B

e$B;d$,;W$&$K$OA4It$OBP1~$9$kI,MW$,$J$/$F!"e(B
cgi.form(key=>val,Key=>Val)'e$B$H=q$/?M$O$^$:$$$J$$$H;W$$$^$9!#e(B
[email protected]!e(B
cgi.form(method=>post)e$B$H=q$/?M$O$$$k$H;W$$$^$9!#e(B
e$B$&!<$s![email protected]$1BP1~$7$F$bH>C<[email protected]$J$!!#e(B

[email protected]$G$9!#e(B

At Tue, 26 Sep 2006 13:29:45 +0900,
Nobuyoshi N. wrote in [ruby-dev:29606]:

e$B$?$V$se(Battributee$B$K$J$ke([email protected],2=$9$kI,MW$,$e(B
e$B$k$s$G$7$g$&$M!#$$$D$d$k$+$J$!#e(B

cgi.rbe$B$r<N$F$k$H$-e(B?

e$B;W$$$C$-$j4V0c$($F$^$7$?!#e(B

Index: lib/cgi.rb

RCS file: /pub/cvs/ruby/lib/cgi.rb,v
retrieving revision 1.68.2.18
diff -U 2 -p -u -r1.68.2.18 cgi.rb
lib/cgi.rb 23 Sep 2006 12:47:11 -0000 1.68.2.18
+++ lib/cgi.rb 26 Sep 2006 08:01:38 -0000
@@ -1229,4 +1229,24 @@ class CGI
module TagMaker # :nodoc:

  • module AttributeChecker
  •  def attribute_check(attributes)
    
  •    canonical = {}
    
  •    attributes.each do |key, value|
    
  •      if old = canonical[upper = key.upcase]
    
  •        raise ArgumentError,
    
  •          "duplcate keys in different cases: #{old} and #{key}"
    
  •      end
    
  •      canonical[upper] = key
    
  •    end
    
  •  end
    
  • end
  • def self.extend_object(obj)
  •  super
    
  •  class << obj
    
  •    include(AttributeChecker)
    
  •  end
    
  • end
  • Generate code for an element with required start and end tags.

@@ -1248,4 +1268,5 @@ class CGI
def nOE_element_def(element, append = nil)
s = <<-END

  •      attribute_check(attributes)
         "<#{element.upcase}" + attributes.collect{|name, value|
           next unless value
    

@@ -1543,10 +1564,6 @@ class CGI
ENCTYPE => enctype }
else

  •                 unless method.has_key?("METHOD")
    
  •                   method["METHOD"] = "post"
    
  •                 end
    
  •                 unless method.has_key?("ENCTYPE")
    
  •                   method["ENCTYPE"] = enctype
    
  •                 end
    
  •                 method["METHOD"] ||= "post"
    
  •                 method["ENCTYPE"] ||= enctype
                    method
                  end
    

@@ -1636,5 +1653,10 @@ class CGI
elsif PRETTY == attributes
attributes = { PRETTY => true }

  •  elsif attributes.kind_of?(Hash)
    
  •    attributes["PRETTY"] ||= false
    
  •  else
    
  •    raise ArgumentError, "Hash expected (#{attributes.class})"
     end
    
  •  attribute_check(attributes)
     pretty = attributes.delete("PRETTY")
     pretty = "  " if true == pretty

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message Re: [ruby-dev:29610] Re: cgi.rbe$B$Ne(Bforme$B$N5sF0e(B
on Tue, 26 Sep 2006 17:26:47 +0900, Nobuyoshi N.
[email protected] writes:

|At Tue, 26 Sep 2006 13:29:45 +0900,
|Nobuyoshi N. wrote in [ruby-dev:29606]:
|> > e$B$?$V$se(Battributee$B$K$J$ke([email protected],2=$9$kI,MW$,$e(B
|> > e$B$k$s$G$7$g$&$M!#$$$D$d$k$+$J$!#e(B
|>
|> cgi.rbe$B$r<N$F$k$H$-e(B?
|
|e$B;W$$$C$-$j4V0c$($F$^$7$?!#e(B

e$BJ}8~$H$7$F$O$=$l$GNI$$$H;W$$$^$9!#%(%i!<$r=P$9$N$He(B(e$BLdEzL5MQe(B
e$B$Ge(B)e$B%^!<%8$9$k$N$H$I$C$A$,NI$$$H;W$$$^$9$+!)e(B

e$BF#2,$G$9!#e(B

e$BJ}8~$H$7$F$O$=$l$GNI$$$H;W$$$^$9!#%(%i!<$r=P$9$N$He(B(e$BLdEzL5MQe(B
e$B$Ge(B)e$B%^!<%8$9$k$N$H$I$C$A$,NI$$$H;W$$$^$9$+!)e(B

e$B%(%i!<[email protected]$7$?$i:#$^$G$h$/$o$+$i$:$K;H$C$F$$$k?M$,$$$-$J$jNc30H/@8$7$Fe(B
e$BF0$+$J$/$J$C$F$7$^$$$^$9$N$G!"%^!<%8$,$$$$$H;W$$$^$9!#e(B
1.9e$B$G$O%(%i!<$G!e(B1.8e$B$G$O%^!<%8$G$H$$$&$N$O$I$&$G$7$g$&$+!#e(B
e$B$&!<$s![email protected]$C$?$iA4It%^!<%8$G$b$$$$$+$J!#e(B
1.9e$B$O$o$+$j$^$;$s$,!"e([email protected]$r9M$($k$H%(%i!<$Oe(B
e$B$d$a$?$[$&$,$$$$$H;W$$$^$9!#e(B

e$BLZB<$G$9!#e(B

e$B=EH"$N6y$G$9$,e(B

On Tue, 26 Sep 2006 17:26:47 +0900
Nobuyoshi N. [email protected] wrote:

  •          "duplcate keys in different cases: #{old} and #{key}"
    

duplicate e$B$Ne(Btypoe$B$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