[Feature #542] cgi.rb : CGI::unescape return encoding

Feature #542: cgi.rb : CGI::unescape return encoding
http://redmine.ruby-lang.org/issues/show/542

e$B5/I<<Te(B: Takeyuki F.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal

CGI::unescapee$B$O8=:_$O0z?t$Ne(Bencodinge$B$Ge(Bforce_encodinge$B$9$k$h$&$Ke(B
e$B$J$C$F$$$^$9$,!"e(Bascii_only?e$B$,e(Btruee$B$N>l9g$Oe(BUS-ASCIIe$B!"e(B
falsee$B$N>l9g$Oe(BASCII-8BITe$B$rJV$9$N$,$$$$$H;W$$$^$9!#e(B

Index: lib/cgi.rb

— lib/cgi.rb (e$B%j%S%8%g%se(B 19071)
+++ lib/cgi.rb (e$B:n6H%3%T!<e(B)
@@ -349,10 +349,10 @@

string = CGI::unescape("%27Stop%21%27+said+Fred")

# => “‘Stop!’ said Fred”

def CGI::unescape(string)

  • enc = string.encoding
  • string.tr(’+’, ’ ').gsub(/((?:%[0-9a-fA-F]{2})+)/) do
  •  [$1.delete('%')].pack('H*').force_encoding(enc)
    
  • str=string.tr(’+’, ’ ').gsub(/((?:%[0-9a-fA-F]{2})+)/) do
  •  [$1.delete('%')].pack('H*')
    
    end
  • str.ascii_only? ? str.force_encoding(“US-ASCII”) :
    str.force_encoding(“ASCII-8BIT”)
    end

TABLE_FOR_ESCAPE_HTML__ = {

e$B%A%1%C%He(B #542 e$B$,99?7$5$l$^$7$?!#e(B (by Takeyuki F.)

[email protected]$N%F%9%H$rDI2Ce(B
Index: test/cgi/test_cgi_class_method.rb

— test/cgi/test_cgi_class_method.rb (e$B%j%S%8%g%se(B 0)
+++ test/cgi/test_cgi_class_method.rb (e$B%j%S%8%g%se(B 0)
@@ -0,0 +1,21 @@
+require ‘test/unit’
+require ‘cgi’
+
+
+class CGIClassMethodTest < Test::Unit::TestCase

  • def test_cgi_class_method_escape
  • assert_equal(CGI::unescape(“Hello”),“Hello”)

assert_equal(CGI::unescape(“Hello%21%22%25%26%27%28%29-%3D%5E%7E%7C”),

  •  "Hello!\"#$\%&'()-=^~|")
    

unescaped=CGI::unescape("%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF")
+
assert_equal(unescaped,"\xE3\x81\x93\xE3\x82\x93\xE3\x81\xAB\xE3\x81\xA1\xE3\x81\xAF")

  • if RUBY_VERSION>=“1.9.0”
  •  assert_equal(CGI::unescape("Hello").encoding,Encoding::US_ASCII)
    

assert_equal(CGI::unescape(“Hello%21%22%25%26%27%28%29-%3D%5E%7E%7C”).encoding,

  •               Encoding::US_ASCII)
    
  •  assert_equal(unescaped.encoding,Encoding::ASCII_8BIT)
    
  • end
  • end
    +end

http://redmine.ruby-lang.org/issues/show/542

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

CGI::unescapee$B$O8=:_$O0z?t$Ne(Bencodinge$B$Ge(Bforce_encodinge$B$9$k$h$&$Ke(B
e$B$J$C$F$$$^$9$,!"e(Bascii_only?e$B$,e(Btruee$B$N>l9g$Oe(BUS-ASCIIe$B!"e(B
falsee$B$N>l9g$Oe(BASCII-8BITe$B$rJV$9$N$,$$$$$H;W$$$^$9!#e(B

e$B0z?t$K$b$H$b$HHse(BASCIIe$BJ8;z$,F~$C$F$$$?>l9g$K$O$I$&$J$j$^$9$+$M!#e(B

e$B$=$NItJ,$O2?$bJQ49$5$l$^$;$s!#e(B
e$B%(%s%3!<%G%#%s%0$Oe(BASCII-8BITe$B$K$J$j$^$9!#e(B

In article [email protected],
Takeyuki F. [email protected] writes:

CGI::unescapee$B$O8=:_$O0z?t$Ne(Bencodinge$B$Ge(Bforce_encodinge$B$9$k$h$&$Ke(B
e$B$J$C$F$$$^$9$,!"e(Bascii_only?e$B$,e(Btruee$B$N>l9g$Oe(BUS-ASCIIe$B!"e(B
falsee$B$N>l9g$Oe(BASCII-8BITe$B$rJV$9$N$,$$$$$H;W$$$^$9!#e(B

e$B0z?t$K$b$H$b$HHse(BASCIIe$BJ8;z$,F~$C$F$$$?>l9g$K$O$I$&$J$j$^$9$+$M!#e(B

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

Takeyuki F. wrote:

CGI::unescapee$B$O8=:_$O0z?t$Ne(Bencodinge$B$Ge(Bforce_encodinge$B$9$k$h$&$Ke(B
e$B$J$C$F$$$^$9$,!"e(Bascii_only?e$B$,e(Btruee$B$N>l9g$Oe(BUS-ASCIIe$B!"e(B
falsee$B$N>l9g$Oe(BASCII-8BITe$B$rJV$9$N$,$$$$$H;W$$$^$9!#e(B

ascii_only? e$B$J$H$-$Ke(B US-ASCII e$B$rJV$9$N$O$$$$$H;W$&$N$G$9$,!"e(B
false e$B$J$H$-$Ke(B ASCII-8BIT e$B$O$^$:$$$G$9$M!#e(B

HTTP e$B%X%C%@$Ge(B charset e$B$r;XDj$5$l$D$De(B escape
e$B$5$l$FEO$5$l$?>l9g!“e(B
e$B$H$j$”$($:e(B escape e$B$5$l$?J8;zNs$K$=$Ne(B charset e$B$r$D$1!“e(B
e$B$=$N8e$Ke(B unescape e$B$9$k$C$F$N$O$=$l$J$j$K$”$j$&$kN.$l$J$N$G!#e(B

Ruby M17N e$B$G$O!“0lO”$N=hM}$N7k2L$Ne(B encoding e$B$r;XDj$9$k:]$K!"e(B
e$B0z?t$Ne(B String#encodig
e$B$rMQ$$$k$H$$$&$3$H$O$7$P$7$P9T$o$l$^$9!#e(B

In article [email protected],
Fujioka [email protected] writes:

e$B$=$NItJ,$O2?$bJQ49$5$l$^$;$s!#e(B
e$B%(%s%3!<%G%#%s%0$Oe(BASCII-8BITe$B$K$J$j$^$9!#e(B

[ruby-dev:36138] e$B$N<BAu$Oe(B (e$B0z?t$,e(B ASCII-8BIT
e$B0J30$GHse(BASCIIe$BJ8e(B
e$B;z$,F~$C$F$$$l$Pe(B) e$BNc30$K$J$j$=$&$G$9$,!"$=$s$J$3$H$O$"$j$^$;e(B
e$B$s$+e(B?

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

Fujioka wrote:

e$B%/%(%j$rEO$5$l$?>l9g$O$=$N%/%(%j$Ke(Bencodinge$B$r$D$1$Fe(B
unescapee$B$9$k$N$G$O$J$/$F!"e(Bunescapee$B$r$7$F$+$ie(B
encodinge$B$r$D$1$k$N$,[email protected]$7$$$H;W$$$^$9!#e(B
e$B%/%(%j$ODL>o$Oe(Basciie$BJ8;zNs$N$O$:$J$N$G!"e(B
e$B$=$l$Ke(Bencodinge$B$r$D$1$kJ}$,4V0c$C$F$$$k$H;W$$$^$9!#e(B

[email protected]!":#;W$C$F$$$k$N$Oe(BASCIIe$B0J30$Oe(BASCII-8BITe$B$K$J$k$N$Oe(B
e$B$"$s$^[email protected]$H;W$C$F$$$F!“e(BCGI.newe$B$7$?$H$-$K%%W%7%g%s$Ge(B
e$B4|BT$9$ke(Bencodinge$B$rEO$7$F$"$2$l$Pe(B
e$B<+F0E
$Ke(BUS-ASCIIe$B$+$=$l0J30$N>l9g$O$=$Ne(Bencodinge$B$Ke(Bforce_encodinge$B$7$Fe(B
e$B$”$2$k5!G=$,M_$7$$$H;W$C$F$$$^$9!#e(B
e$B$^[email protected]$G$9$,!#e(B

Ruby M17N e$B$G$O!“0lO”$N=hM}$N7k2L$Ne(B encoding e$B$r;XDj$9$k:]$K!"e(B
e$B0z?t$Ne(B String#encodig e$B$rMQ$$$k$H$$$&$3$H$O$7$P$7$P9T$o$l$^$9!#e(B

unescapee$B$Oe(Basciie$B$+$ie(Basciie$B$+$I$&$+$o$+$i$J$$J8;zNs$X$N%U%#%k%?$J$N$Ge(B
e$B0z?t$Ne(Bencodinge$B$O$"$F$K$G$-$J$$$H;W$C$F$$$^$9!#e(B

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

e$B$=$NItJ,$O2?$bJQ49$5$l$^$;$s!#e(B
e$B%(%s%3!<%G%#%s%0$Oe(BASCII-8BITe$B$K$J$j$^$9!#e(B

[ruby-dev:36138] e$B$N<BAu$Oe(B (e$B0z?t$,e(B ASCII-8BIT e$B0J30$GHse(BASCIIe$BJ8e(B
e$B;z$,F~$C$F$$$l$Pe(B) e$BNc30$K$J$j$=$&$G$9$,!"$=$s$J$3$H$O$"$j$^$;e(B
e$B$s$+e(B?

e$B$D$^$je(Bencodinge$B$,4V0c$C$F$$$k>l9g$H$$$&$3$H$G$9$+!)e(B
e$B$=$N>l9g$ONc30$G$b$$$$$h$&$J!#!#!#e(B
ASCII-8BITe$B$KJQ49$7$F$+$i=hM}$7$FNc30$r=P$5$J$$J}$,$$$$$G$7$g$&$+!)e(B

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

[email protected]!":#;W$C$F$$$k$N$Oe(BASCIIe$B0J30$Oe(BASCII-8BITe$B$K$J$k$N$Oe(B
e$B$"$s$^[email protected]$H;W$C$F$$$F!“e(BCGI.newe$B$7$?$H$-$K%%W%7%g%s$Ge(B
e$B4|BT$9$ke(Bencodinge$B$rEO$7$F$"$2$l$Pe(B
e$B<+F0E
$Ke(BUS-ASCIIe$B$+$=$l0J30$N>l9g$O$=$Ne(Bencodinge$B$Ke(Bforce_encodinge$B$7$Fe(B
e$B$”$2$k5!G=$,M_$7$$$H;W$C$F$$$^$9!#e(B
e$B$^[email protected]$G$9$,!#e(B

e$B$3$l$K$D$$$F$G$9$,!“e(B
[email protected]@%$5$s$H$d$j<h$j$r$7$?7k2L!”$d$O$j%X%C%@$Ne(Bcharsete$B$r8+$Fe(B
e$B$=$Ne(Bencodinge$B$r$D$1$F$"$2$k$N$,[email protected]$m$&$H$$$&OC$K$J$j$^$7$?!#e(B

In article [email protected],
Fujioka [email protected] writes:

e$B$D$^$je(Bencodinge$B$,4V0c$C$F$$$k>l9g$H$$$&$3$H$G$9$+!)e(B

e$B$$$(!#e(Bencoding e$B$H$7$F4V0c$C$F$$$J$/$F$b!#e(B

In article [email protected],
Fujioka [email protected] writes:

[email protected]@%$5$s$H$d$j<h$j$r$7$?7k2L!"$d$O$j%X%C%@$Ne(Bcharsete$B$r8+$Fe(B
e$B$=$Ne(Bencodinge$B$r$D$1$F$"$2$k$N$,[email protected]$m$&$H$$$&OC$K$J$j$^$7$?!#e(B

e$B%V%i%&%6$O$3$3$GMxMQ$G$-$ke(B charset e$B$r$D$1$F$/$l$k$s$G$7$g$&e(B
e$B$+e(B?

e$B%A%1%C%He(B #542 e$B$,99?7$5$l$^$7$?!#e(B (by Takeyuki F.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BRejectede$B$KJQ99e(B

e$B$$$:$le(Bencodinge$B$N<+F0IUM?5!G=$rEk:$9$k$H$$$&$3$H$G!"e(B
e$B$3$N%A%1%C%H$OJD$8$^$9!#e(B

http://redmine.ruby-lang.org/issues/show/542

On Wed, 10 Sep 2008 13:51:26 +0900
In article [email protected]
[[ruby-dev:36239] Re: [Feature #542] cgi.rb : CGI::unescape return
encoding]
Tanaka A. [email protected] wrote:

In article [email protected],
Fujioka [email protected] writes:

[email protected]@%$5$s$H$d$j<h$j$r$7$?7k2L!"$d$O$j%X%C%@$Ne(Bcharsete$B$r8+$Fe(B
e$B$=$Ne(Bencodinge$B$r$D$1$F$"$2$k$N$,[email protected]$m$&$H$$$&OC$K$J$j$^$7$?!#e(B

e$B%V%i%&%6$O$3$3$GMxMQ$G$-$ke(B charset e$B$r$D$1$F$/$l$k$s$G$7$g$&e(B
e$B$+e(B?

application/x-www-form-urlencoded e$B$K$O$=$b$=$be(B charset
e$B$,$"$j$^$;$s$7!"e(B
multipart/form-data e$B$K$be(B charset
e$B$,IU$$$F$$$k$N$O8+$?$3$H$,$J$$$G$9!#e(B

On Wed, 10 Sep 2008 14:33:34 +0900
In article [email protected]
[[ruby-dev:36241] Re: [Feature #542] cgi.rb : CGI::unescape return
encoding]
Fujioka [email protected] wrote:

e$B$G$b!“Nc$($Pe(BUTF-8e$B$r4|BT$7$F$$$k%”%W%j$Ke(BEUC-JPe$B$r%]%9%H$7$Fe(B
e$BNc30$,5/$-$k$N$O9%$^$7$/$"$j$^$;$s$M!#9M$($^$9!#e(B

e$B4|BT$7$F$$$k$N$H0c$&J8;z%;%C%H!"$"$k$$$O2u$l$?J8;zNs$rEO$7!“e(BXSSe$B$r5/$3$9e(B
e$B$H$$$&967b$,$”$k$N$G!"$`$7$mNc30$NJ}$,$"$j$,$?$$$+$b$7$l$^$;$s!#e(B

begin
cgi = CGI.new(:assume_encoding => ‘UTF-8’)
rescue CGI::InvalidEncodingError
print “Status: 400 Bad Request\n\n”
exit
end

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

[email protected]@%$5$s$H$d$j<h$j$r$7$?7k2L!"$d$O$j%X%C%@$Ne(Bcharsete$B$r8+$Fe(B
e$B$=$Ne(Bencodinge$B$r$D$1$F$"$2$k$N$,[email protected]$m$&$H$$$&OC$K$J$j$^$7$?!#e(B

e$B%V%i%&%6$O$3$3$GMxMQ$G$-$ke(B charset e$B$r$D$1$F$/$l$k$s$G$7$g$&e(B
e$B$+e(B?

e$B$$$(!"$D$1$F$/$l$^$;$s!#e(B
e$B$"$/$^$Ge(BCGIe$B%"%W%jB&$,4|BT$9$k$3$H$K$J$j$^$9!#e(B

e$B$G$b!“Nc$($Pe(BUTF-8e$B$r4|BT$7$F$$$k%”%W%j$Ke(BEUC-JPe$B$r%]%9%H$7$Fe(B
e$BNc30$,5/$-$k$N$O9%$^$7$/$"$j$^$;$s$M!#9M$($^$9!#e(B

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

[email protected]@%$5$s$H$d$j<h$j$r$7$?7k2L!"$d$O$j%X%C%@$Ne(Bcharsete$B$r8+$Fe(B
e$B$=$Ne(Bencodinge$B$r$D$1$F$"$2$k$N$,[email protected]$m$&$H$$$&OC$K$J$j$^$7$?!#e(B
e$B%V%i%&%6$O$3$3$GMxMQ$G$-$ke(B charset e$B$r$D$1$F$/$l$k$s$G$7$g$&e(B
e$B$+e(B?

application/x-www-form-urlencoded e$B$K$O$=$b$=$be(B charset e$B$,$"$j$^$;$s$7!"e(B
multipart/form-data e$B$K$be(B charset e$B$,IU$$$F$$$k$N$O8+$?$3$H$,$J$$$G$9!#e(B

encodinge$B>pJs$O$b$i$($J$$$N$G!"4|BT$9$k$7$+$J$$$G$9!#e(B
[email protected]$+$i$H$$$C$Fe(BASCII-8BITe$B$+e(BUS-ASCIIe$B$N$I$A$i$G$7$+e(B
e$B%G!<%?$rLc$($J$$$H$$$&$N$bLLE]$+$J$H;W$&$N$G$9$,!"e(B
e$B$I$&$7$?$i$$$$$H;W$$$^$9$+!)e(B

e$B%]%9%H$5$l$?%G!<%?$Oe(B

1.ASCII-8BIT e$B$G$b$i$&!J8=>u!Ke(B
2.US-ASCII or ASCII-8BIT e$B$G$b$i$&e(B
3.e$B4|BT$9$ke(Bencodinge$B$r7h$a$F!"e(BUS-ASCII or
e$B4|BT$9$ke(Bencodinge$B$G$b$i$&e(B
4.e$B>e5-e(B3e$B$K2C$($F!"e(Bencodinge$B%A%’%C%/$r$*$3$J$C$F!"e(Bencodinge$B$,4V0c$C$F$$$ke(B
e$B>l9g$Oe(Bnile$B$J$I$rJV$9e(B

1e$B$He(B2e$B$OF|K\8l$Ne(BCGIe$B%"%W%j$N=PNO$,LLE]$G$9!#e(B
@cgi=CGI.new
e$B$7$?$H$7$F!"%]%9%H$5$l$?%G!<%?$KF|K\8l$,F~$C$F$/$k$He(B
“e$B%?%$%H%ke(B:#{@cgi[‘title’]}”
e$B$3$l$,Nc30$G$9!#e(B
e$BF|K\8lJ8;zNs$He(BASCII-8BITe$B$,O"7k$G$-$J$$$?$a$G$9!#e(B
e$B$3$l$G$O;H$$$E$i$$$J$!$H;W$C$F%"%$%G%#%"$rLO:w$7$F$$$k:GCf$G$9!#e(B

In article [email protected],
Fujioka [email protected] writes:

encodinge$B>pJs$O$b$i$($J$$$N$G!"4|BT$9$k$7$+$J$$$G$9!#e(B
[email protected]$+$i$H$$$C$Fe(BASCII-8BITe$B$+e(BUS-ASCIIe$B$N$I$A$i$G$7$+e(B
e$B%G!<%?$rLc$($J$$$H$$$&$N$bLLE]$+$J$H;W$&$N$G$9$,!"e(B
e$B$I$&$7$?$i$$$$$H;W$$$^$9$+!)e(B

e$B%"%W%j%1!<%7%g%s$,4|BT$9$k%(%s%3!<%G%#%s%0$re(B cgi.rb e$B$Ke(B
e$B65$($F$d$k$7$+$J$$$7!"$=$&$9$k$N$,NI$$$H;W$$$^$9!#e(B

e$B;EMM$H$7$F$O%V%i%&%6$,%G!<%?$rAw$C$F$/$k860x$H$J$C$?e(B HTML e$B$Ne(B
form e$B$Ne(B accept-charset e$B$re(B cgi.rb e$B$Ke(B
e$B65$($F$d$ke(B (e$B$H$$$&$3$H$K$7$F$*$/e(B)
e$B$s$8$c$J$$$G$7$g$&$+!#e(B

e$B$^$!!"e(Baccept-charset e$B$K8B$i$:e(B form
e$B$N>pJs$r65$($F$d$k$H$$$me(B
e$B$$$m8!::$G$-$F$$$$$+$b$7$l$^$;$s$,!#e(B

In article [email protected],
Fujioka [email protected] writes:

e$BAw$i$l$F$/$ke(BForme$B$Ke(Baccept-charsete$B$r$D$1$F$b!“e(B
IEe$B$be(BFirefoxe$B$bBP1~$7$F$$$J$$$N$G!”<B<AL50UL#[email protected]$H;W$$$^$9!#e(B

[email protected]$,B-$j$J$+$C$?$h$&$G$9!#e(B

Web e$B%5!<%P$,e(B form e$B$r4^$`e(B HTML
e$B$rAw$C$?;~$K!"%V%i%&%6$,$I$N$he(B
e$B$&$Je(B charset e$B$GJV;v$re(B Web e$B%5!<%PJV$9$Y$-$+$re(B
accept-charset
e$B$N$h$&[email protected]<(E*$J7A$d!“e(BHTML e$B<+BN$Ne(B encoding
e$B$H$7$F0EL[$J7A$Ge(B
e$B;X<($7$F$$$k$N$G!”$=$N;X<($re(B cgi.rb e$B$K65$($F$d$k$H$$$&0UL#$re(B
e$B0U?^$7$F$$$^$7$?!#e(B

e$B$J$*!"<j85$Ne(B iceweasel 2.0.0.16 e$B$Oe(B accept-charset
e$B$rM}2r$7$Fe(B
e$B=>$&$h$&$G$9!#e(B

[email protected]$Ge(Baccept-charsete$B$rAw$k$H$$$&$3$H$G$9$+!)e(B
[email protected]$C$?$i8=<BE*$+$J!#e(B

[email protected]$O9M$($F$$$^$;$s!#e(B

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

Tanaka A. e$B$5$s$O=q$-$^$7$?e(B:

encodinge$B>pJs$O$b$i$($J$$$N$G!"4|BT$9$k$7$+$J$$$G$9!#e(B
[email protected]$+$i$H$$$C$Fe(BASCII-8BITe$B$+e(BUS-ASCIIe$B$N$I$A$i$G$7$+e(B
e$B%G!<%?$rLc$($J$$$H$$$&$N$bLLE]$+$J$H;W$&$N$G$9$,!"e(B
e$B$I$&$7$?$i$$$$$H;W$$$^$9$+!)e(B

e$B%"%W%j%1!<%7%g%s$,4|BT$9$k%(%s%3!<%G%#%s%0$re(B cgi.rb e$B$Ke(B
e$B65$($F$d$k$7$+$J$$$7!"$=$&$9$k$N$,NI$$$H;W$$$^$9!#e(B

e$BN;2r$G$9!#e(B

e$B;EMM$H$7$F$O%V%i%&%6$,%G!<%?$rAw$C$F$/$k860x$H$J$C$?e(B HTML e$B$Ne(B
form e$B$Ne(B accept-charset e$B$re(B cgi.rb e$B$Ke(B
e$B65$($F$d$ke(B (e$B$H$$$&$3$H$K$7$F$*$/e(B) e$B$s$8$c$J$$$G$7$g$&$+!#e(B

e$BAw$i$l$F$/$ke(BForme$B$Ke(Baccept-charsete$B$r$D$1$F$b!“e(B
IEe$B$be(BFirefoxe$B$bBP1~$7$F$$$J$$$N$G!”<B<AL50UL#[email protected]$H;W$$$^$9!#e(B
[email protected]$Ge(Baccept-charsete$B$rAw$k$H$$$&$3$H$G$9$+!)e(B
[email protected]$C$?$i8=<BE*$+$J!#e(B

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

Web e$B%5!<%P$,e(B form e$B$r4^$`e(B HTML e$B$rAw$C$?;~$K!"%V%i%&%6$,$I$N$he(B
e$B$&$Je(B charset e$B$GJV;v$re(B Web e$B%5!<%PJV$9$Y$-$+$re(B accept-charset
e$B$N$h$&[email protected]<(E*$J7A$d!“e(BHTML e$B<+BN$Ne(B encoding e$B$H$7$F0EL[$J7A$Ge(B
e$B;X<($7$F$$$k$N$G!”$=$N;X<($re(B cgi.rb e$B$K65$($F$d$k$H$$$&0UL#$re(B
e$B0U?^$7$F$$$^$7$?!#e(B

e$B$J$*!"<j85$Ne(B iceweasel 2.0.0.16 e$B$Oe(B accept-charset e$B$rM}2r$7$Fe(B
e$B=>$&$h$&$G$9!#e(B

e$B$d$O$j!“[email protected]<(E*$Ke(Bcgi.rbe$B$N%$%s%9%?%s%9$KEA$($F$*$$$?J}$,$h$5$=$&$G$9$M!#e(B
e$B%(%i!<=hM}$H$+2?$b$^[email protected]$J$$$G$9$,!“e(B
e$B$H$j$”$($:2<$N%Q%C%A$G0J2<$N$h$&$Je(BCGIe$B%”%W%j$OF0$-$^$9!#e(B
e$B$3$NJ}?K$H$7$F$O$$$+$,$G$7$g$&$+!)!d$[$+$N0U8+$"$j$=$&$JJ}!9e(B

e$B$"$H!"%(%s%3!<%G%#%s%0$,0c$&J8;zNs$rAw$j$D$1$i$l$?>l9g$Ke(B
e$B$I$&$9$k$+$G$9$,!"e(B

  1. e$BJ|CV!J$*$=$i$/$I$3$+$GNc30$r5/$3$7$F;_$^$k!Ke(B
  2. e$B8!>Z$7$F$*$+$7$+$C$?$H$-$Oe(Bkeye$B$4$HL5;k$9$ke(B

e$B8!>Z$7$F$$+$7$+$C$?$H$-$Oe(Bkeye$B$O$"$k$1$ICf?H$re(Bnile$B$K$9$ke(B
4.
e$B8!>Z$7$F$
$+$7$+$C$?$H$-$Oe(Bvaluee$B$re(BASCII-8BITe$B$K$7$F$7$^$&e(B
4e$B$,[email protected]$+$J$H;W$&$N$G$9$,!"$40U8+$h$m$7$/$*4j$$$7$^$9!#e(B

#!/Users/fujioka/local/bin/ruby19

vim:fileencoding=UTF-8

require ‘cgi’
@cgi=CGI.new(“html3”,“UTF-8”)
@header = { “type” => “text/html”, “charset” => “UTF-8” }

@cgi.out(@header) do
@cgi.html do
@cgi.head{@cgi.title{“e$B$?$$$H$ke(B”}}+
@cgi.body do
“e$B7k2Le(B:#{@cgi[‘title’]}”+
@cgi.form(“action”=>@cgi.script_name) do
@cgi.text_field(“name”=>“title”)+
@cgi.hidden(“name”=>“key”,“value”=>“value”)+
@cgi.submit(“value”=>“OK”)
end
end
end
end

Index: lib/cgi/core.rb

— lib/cgi/core.rb (revision 19280)
+++ lib/cgi/core.rb (working copy)
@@ -600,7 +600,7 @@

stdinput.read(Integer(env_table[‘CONTENT_LENGTH’])) or ‘’
else
read_from_cmdline

  •                end
    
  •                end.force_encoding(@encoding)
                 )
     end
    

@@ -667,7 +667,8 @@

from the command line or (failing that) from standard input.

Otherwise,

cookies and other parameters are parsed automatically from the

standard

CGI locations, which varies according to the REQUEST_METHOD.

  • def initialize(type = “query”)
  • def initialize(type = “query”,encoding=“ASCII-8BIT”)
  • @encoding=encoding
    if defined?(MOD_RUBY) && !ENV.key?(“GATEWAY_INTERFACE”)
    Apache.request.setup_cgi_env
    end