Skip to content

Commit

Permalink
Fixing Camping.method_missing and unescape incoming urls
Browse files Browse the repository at this point in the history
  • Loading branch information
judofyr committed Nov 27, 2008
1 parent e76e7ac commit bf97ad1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/camping-unabridged.rb
Expand Up @@ -416,7 +416,7 @@ def initialize(env) #:nodoc:
Rack::Request.new(env), Rack::Response.new, env
@root, @input, @cookies,
@headers, @status =
@env.SCRIPT_NAME.sub(/\/$/,''),
(@env.SCRIPT_NAME||'').sub(/\/$/,''),
H[@request.params], H[@request.cookies],
@response.headers, @response.status

Expand Down Expand Up @@ -560,6 +560,7 @@ def goes(m)
def call(e)
X.M
e = H[e.to_hash]
e.PATH_INFO = U.unescape(e.PATH_INFO)
k,m,*a=X.D e.PATH_INFO,(e.REQUEST_METHOD||'get').downcase
e.REQUEST_METHOD = m
k.new(e).service(*a).to_a
Expand Down
5 changes: 3 additions & 2 deletions lib/camping.rb
Expand Up @@ -27,7 +27,7 @@ def r s,b,h={};b,h=h,b if Hash===b;@status=s;
@response.to_a;end;def initialize(env)
@request,@response,@env=Rack::Request.new(env),Rack::Response.new,env
@root,@input,@cookies,@headers,@status=
@env.SCRIPT_NAME.sub(/\/$/,''),H[@request.params],
(@env.SCRIPT_NAME||'').sub(/\/$/,''),H[@request.params],
H[@request.cookies],@response.headers,@response.status
@input.each{|k,v|if k[-2..-1]=="[]";@input[k[0..-3]]=
@input.delete(k)elsif k=~/(.*)\[([^\]]+)\]$/
Expand All @@ -45,7 +45,8 @@ def M;def M;end;constants.map{|c|k=const_get(c)
}if !k.respond_to?:urls}end end;class I<R()
end; end;X=Controllers;class<<self;def goes m
Apps<<eval(S.gsub(/Camping/,m.to_s),TOPLEVEL_BINDING) end;def call(
e)X.M;e=H[e.to_hash];k,m,*a=X.D e.PATH_INFO,(e.REQUEST_METHOD||'get').downcase
e)X.M;e=H[e.to_hash];e.PATH_INFO=U.unescape e.PATH_INFO
k,m,*a=X.D e.PATH_INFO,(e.REQUEST_METHOD||'get').downcase
e.REQUEST_METHOD=m;k.new(e).service(*a).to_a;end
def method_missing m,c,*a;X.M;h=Hash===a[-1]?H[a.pop]:{};e=
H[h[:env]||{}].merge!({'rack.input'=>StringIO.new,'REQUEST_METHOD'=>m.to_s})
Expand Down

0 comments on commit bf97ad1

Please sign in to comment.