URI.decode_www_form("?a=b")

URI.decode_www_form e$B$O!“[email protected],$K$”$ke(B ? e$B$rL5;k$7$^$9!#e(B

% ./ruby -ruri -ve ‘p URI.decode_www_form("?a=b")’
ruby 1.9.2dev (2010-04-08 trunk 27262) [i686-linux]
[[“a”, “b”]]
% ./ruby -ruri -ve ‘p URI.decode_www_form(“a=b”)’
ruby 1.9.2dev (2010-04-08 trunk 27262) [i686-linux]
[[“a”, “b”]]

e$B0U?^$OJ,$+$k$s$G$9$,!";DG0$J$3$H$K!"e(BURI e$B$Ne(B query e$B$K$Oe(B
? e$B$H$$$&J8;z$re(B
e$BF~$l$i$l$^$9!#e(B

RFC 3986:

  query       = *( pchar / "/" / "?" )

e$B$=$N$?$a!“e(B? e$B$G;O$^$ke(B key
e$B$b$A$c$s$H07$&$K$O$I$&[email protected]$G$O$”$j$^$;$s!#e(B
e$B$3$3$Oe(B ?
e$B$NFCJL07$$$r$"$-$i$a$?$[$&$,$$$$$s$8$c$J$$$G$7$g$&$+!#e(B

e$B$"$H!"$=$Ne(B

unless /\A\??(?<query>[^=;&]*=[^;&]*(?:[;&][^=;&]*=[^;&]*)*)\z/ =~ 

str

e$B$H$$$&$H$3$m$G!"e(B[^;&]* e$B$H$$$&%Q%?!<%s$,;H$o$l$F$$$F!“e(B
[email protected]$7$$e(B application/x-www-form-urlencoded
e$B$G$”$k$3$H$r8!::$7$F$$$^$;$s!#e(B
e$B$A$c$s$H8!::$7$?$[$&$,$$$$5$$,$9$k$s$G$9$,$I$&$G$7$g$&$+!#e(B

% ./ruby -ruri -e ‘p URI.decode_www_form("%=%")’
[["%", “%”]]

(2010/04/09 18:29), Tanaka A. wrote:

e$BF~$l$i$l$^$9!#e(B

RFC 3986:

   query       = *( pchar / "/" / "?" )

e$B$=$N$?$a!“e(B? e$B$G;O$^$ke(B key e$B$b$A$c$s$H07$&$K$O$I$&[email protected]$G$O$”$j$^$;$s!#e(B
e$B$3$3$Oe(B ? e$B$NFCJL07$$$r$"$-$i$a$?$[$&$,$$$$$s$8$c$J$$$G$7$g$&$+!#e(B

e$B$I$3$+$Ge(B form data e$B$Ne(B POST e$B;~$Ke(B ?
e$B$r4^$a$F$7$^$&<BAu$,$"$k$H$+8+$?$h$&$Je(B
e$B5-21$,$"$k$s$G$9$,!“8+$D$+$i$J$$$N$G!”$=$&$7$^$7$g$&$+!#e(B

e$B$"$H!"$=$Ne(B

 unless /\A\??(?<query>[^=;&]*=[^;&]*(?:[;&][^=;&]*=[^;&]*)*)\z/ =~ str

e$B$H$$$&$H$3$m$G!"e(B[^;&]* e$B$H$$$&%Q%?!<%s$,;H$o$l$F$$$F!“e(B
[email protected]$7$$e(B application/x-www-form-urlencoded e$B$G$”$k$3$H$r8!::$7$F$$$^$;$s!#e(B
e$B$A$c$s$H8!::$7$?$[$&$,$$$$5$$,$9$k$s$G$9$,$I$&$G$7$g$&$+!#e(B

% ./ruby -ruri -e ‘p URI.decode_www_form("%=%")’
[["%", “%”]]

[email protected]$7$$e(B
application/x-www-form-urlencodede$B!W$,$I$NDxEY$NHO0O$^$G$J$N$+$,e(B
e$B$A$g$C$H$h$/$o$+$i$J$$$N$G$9$,!"$3$s$J46$8$G$9$+$M$’!#e(B

WFKV_ = ‘(?:%\h\h|[^%#=;&]+)’ # :nodoc:
def self.decode_www_form(str, enc=Encoding::UTF_8)
return [] if str.empty?
unless /\A#{WFKV_}=#{WFKV_}(?:[;&]#{WFKV_}=#{WFKV_})*\z/o =~ str

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