Skip to content

Commit

Permalink
- WebDAV has no concept of a query string and clients (including cada…
Browse files Browse the repository at this point in the history
…ver)

  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
  • Loading branch information
Hartmut Holzgraefe committed Apr 23, 2008
1 parent 6cae630 commit a81d3b3
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Server.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -2037,7 +2045,7 @@ function _urlencode($url)
*/
function _urldecode($path)
{
return urldecode($path);
return rawurldecode($path);
}

/**
Expand Down

0 comments on commit a81d3b3

Please sign in to comment.