From 9f75b5886f327c9f4a0f92ed30817fa9610f80d4 Mon Sep 17 00:00:00 2001
From: martinlanghoff <martinlanghoff>
Date: Wed, 27 Feb 2008 03:01:56 +0000
Subject: [PATCH] MDL-90 PEAR/HTTP/WebDAV: fix file name encoding ... for real
 this time?

Cherry picked from upstream.
---
 lib/pear/HTTP/WebDAV/Server.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/pear/HTTP/WebDAV/Server.php b/lib/pear/HTTP/WebDAV/Server.php
index e9266349f7..b6983dd4e2 100755
--- a/lib/pear/HTTP/WebDAV/Server.php
+++ b/lib/pear/HTTP/WebDAV/Server.php
@@ -714,6 +714,9 @@ class HTTP_WebDAV_Server
              collections end in a slash, this should be done in here
              by checking the resource attribute */
             $href = $this->_mergePathes($this->_SERVER['SCRIPT_NAME'], $path);
+
+            /* minimal urlencoding is needed for the resource path */
+            $href = $this->_urlencode($href);
         
             echo "  <D:href>$href</D:href>\n";
         
@@ -2008,7 +2011,7 @@ class HTTP_WebDAV_Server
     /**
      * private minimalistic version of PHP urlencode()
      *
-     * only blanks and XML special chars must be encoded here
+     * only blanks, percent and XML special chars must be encoded here
      * full urlencode() encoding confuses some clients ...
      *
      * @param  string  URL to encode
@@ -2017,6 +2020,7 @@ class HTTP_WebDAV_Server
     function _urlencode($url) 
     {
         return strtr($url, array(" "=>"%20",
+                                 "%"=>"%25",
                                  "&"=>"%26",
                                  "<"=>"%3C",
                                  ">"=>"%3E",
-- 
2.39.5