From 80984c1ac816481a46a14f857488d0d9b10f4fe6 Mon Sep 17 00:00:00 2001 From: Magnus Holm Date: Sun, 16 Nov 2008 19:58:52 +0800 Subject: [PATCH] Fixing Camping.method_missing and unescape incoming urls Signed-off-by: why the lucky stiff --- lib/camping-unabridged.rb | 3 ++- lib/camping.rb | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/camping-unabridged.rb b/lib/camping-unabridged.rb index 659cf7c..1149f17 100644 --- a/lib/camping-unabridged.rb +++ b/lib/camping-unabridged.rb @@ -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 @@ -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 diff --git a/lib/camping.rb b/lib/camping.rb index 1c8c521..a2f0562 100644 --- a/lib/camping.rb +++ b/lib/camping.rb @@ -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=~/(.*)\[([^\]]+)\]$/ @@ -45,7 +45,8 @@ def M;def M;end;constants.map{|c|k=const_get(c) }if !k.respond_to?:urls}end end;class IStringIO.new,'REQUEST_METHOD'=>m.to_s})