From 8d735cb60ee4ca15dd9f60f916d001c4b9efb675 Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Mon, 19 Jan 2009 22:22:37 +0000 Subject: fix for COUCHDB-214 (design docs on dbs with slashes) git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@735850 13f79535-47bb-0310-9956-ffa450edef68 --- src/couchdb/couch_httpd_db.erl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/couchdb/couch_httpd_db.erl') diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index cdebb1e3..fc13622d 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -256,9 +256,10 @@ db_req(#httpd{path_parts=[_,<<"_admins">>]}=Req, _Db) -> % Special case to enable using an unencoded slash in the URL of design docs, % as slashes in document IDs must otherwise be URL encoded. db_req(#httpd{method='GET',mochi_req=MochiReq, path_parts=[DbName,<<"_design/",_/binary>>|_]}=Req, _Db) -> - PathFront = "/" ++ binary_to_list(DbName) ++ "/_design", - {ok, [PathFront|PathTail]} = regexp:split(MochiReq:get(raw_path),"%2F"), - RedirectTo = PathFront ++ "/" ++ mochiweb_util:join(PathTail, "%2F"), + PathFront = "/" ++ couch_httpd:quote(binary_to_list(DbName)) ++ "/", + RawSplit = regexp:split(MochiReq:get(raw_path),"_design%2F"), + {ok, [PathFront|PathTail]} = RawSplit, + RedirectTo = PathFront ++ "_design/" ++ mochiweb_util:join(PathTail, "%2F"), couch_httpd:send_response(Req, 301, [{"Location", RedirectTo}], <<>>); db_req(#httpd{path_parts=[_DbName,<<"_design">>,Name]}=Req, Db) -> -- cgit v1.2.3