• R/O
  • SSH
  • HTTPS

tenarai: 提交


Commit MetaInfo

修訂64 (tree)
時間2008-03-27 22:50:05
作者junkikuchi

Log Message

updated.

Change Summary

差異

--- trunk/test/test_cgi.rb (revision 63)
+++ trunk/test/test_cgi.rb (revision 64)
@@ -14,12 +14,12 @@
1414 DATE = Time.local(2007, 6, 5, 22, 10, 0, 0)
1515 DATE_CGI = 'Tue, 05 Jun 2007 13:10:00 GMT'
1616
17- def test_escape
18- assert_equal(A, Tenarai::CGI.escape(B))
17+ def test_encode
18+ assert_equal(A, Tenarai::CGI.encode(B))
1919 end
2020
21- def test_unescape
22- assert_equal(B, Tenarai::CGI.unescape(A))
21+ def test_decode
22+ assert_equal(B, Tenarai::CGI.decode(A))
2323 end
2424
2525 def test_date
--- trunk/lib/tenarai/cgi/response.rb (revision 63)
+++ trunk/lib/tenarai/cgi/response.rb (revision 64)
@@ -31,7 +31,7 @@
3131 end
3232
3333 def to_s
34- a = ["%s=%s" % [@name, CGI.escape(@value)]]
34+ a = ["%s=%s" % [@name, CGI.encode(@value)]]
3535 @expires && a << "expires=%s" % CGI.date(@expires)
3636 @path && a << "path=%s" % @path
3737 @domain && a << "domain=%s" % @domain
--- trunk/lib/tenarai/cgi/query.rb (revision 63)
+++ trunk/lib/tenarai/cgi/query.rb (revision 64)
@@ -19,7 +19,7 @@
1919 def decode(query)
2020 query.to_s.split(/[&;]/).inject(Query.new) do |ret, q|
2121 key, val = q.split('=')
22- ret[CGI.unescape(key)] = CGI.unescape(val)
22+ ret[CGI.decode(key)] = CGI.decode(val)
2323 ret
2424 end
2525 end
@@ -27,10 +27,6 @@
2727
2828 include Enumerable
2929
30- #def initialize(query={})
31- # @query = query
32- #end
33- #
3430 def initialize
3531 @query = {}
3632 end
@@ -75,7 +71,7 @@
7571 if v.empty?
7672 ret << key
7773 else
78- ret << "%s=%s" % [key, CGI.escape(v)]
74+ ret << "%s=%s" % [key, CGI.encode(v)]
7975 end
8076 end
8177 else
@@ -82,7 +78,7 @@
8278 if val.empty?
8379 ret << key
8480 else
85- ret << "%s=%s" % [key, CGI.escape(val)]
81+ ret << "%s=%s" % [key, CGI.encode(val)]
8682 end
8783 end
8884 ret
--- trunk/lib/tenarai/cgi.rb (revision 63)
+++ trunk/lib/tenarai/cgi.rb (revision 64)
@@ -9,11 +9,11 @@
99 module Tenarai
1010 class CGI
1111 class << self
12- def escape(s)
12+ def encode(s)
1313 s.to_s.gsub(/[^\w ]/n) do |c| '%%%02x' % c[0] end.tr(' ', '+')
1414 end
1515
16- def unescape(s)
16+ def decode(s)
1717 s.to_s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n) do
1818 [$1.delete('%')].pack('H*')
1919 end
--- trunk/webapp/Service.rb (revision 63)
+++ trunk/webapp/Service.rb (revision 64)
@@ -97,7 +97,7 @@
9797 aw.min <=> bw.min
9898 end.each do |w, val|
9999 query = val.split(',').map do |v|
100- Tenarai::CGI.unescape(v)
100+ Tenarai::CGI.decode(v)
101101 end
102102 w.init(*query)
103103 end
Show on old repository browser