From a81d3b3b7098e1b5415da945994835f16f8eb67d Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe Date: Wed, 23 Apr 2008 02:56:05 +0000 Subject: [PATCH] - WebDAV has no concept of a query string and clients (including cadaver) seem to pass '?' unencoded, so we need to extract the path info out of the request URI ourselves - this together with using rawurlencode() instead of urlencode() also solves the double encoding issue reported in pear bug #12283 git-svn-id: http://svn.php.net/repository/pear/packages/HTTP_WebDAV_Server/trunk@258286 c90b9560-bf6c-de11-be94-00142212c4b1 --- Server.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Server.php b/Server.php index b6983dd..9947c17 100755 --- a/Server.php +++ b/Server.php @@ -163,7 +163,15 @@ function ServeRequest() } $uri.= "://".$this->_SERVER["HTTP_HOST"].$this->_SERVER["SCRIPT_NAME"]; - $path_info = empty($this->_SERVER["PATH_INFO"]) ? "/" : $this->_SERVER["PATH_INFO"]; + // WebDAV has no concept of a query string and clients (including cadaver) + // seem to pass '?' unencoded, so we need to extract the path info out + // of the request URI ourselves + $path_info = substr($this->_SERVER["REQUEST_URI"], strlen($this->_SERVER["SCRIPT_NAME"])); + + // just in case the path came in empty ... + if (empty($path_info)) { + $path_info = "/"; + } $this->base_uri = $uri; $this->uri = $uri . $path_info; @@ -494,7 +502,7 @@ function checklock($resource) * OPTIONS method handler * * The OPTIONS method handler creates a valid OPTIONS reply - * including Dav: and Allowed: heaers + * including Dav: and Allowed: headers * based on the implemented methods found in the actual instance * * @param void @@ -1518,8 +1526,8 @@ function _copymove($what) $http_header_host = preg_replace("/:80$/", "", $this->_SERVER["HTTP_HOST"]); - $url = parse_url($this->_SERVER["HTTP_DESTINATION"]); - $path = urldecode($url["path"]); + $url = parse_url($this->_SERVER["HTTP_DESTINATION"]); + $path = urldecode($url["path"]); if (isset($url["host"])) { // TODO check url scheme, too @@ -2037,7 +2045,7 @@ function _urlencode($url) */ function _urldecode($path) { - return urldecode($path); + return rawurldecode($path); } /**