[Pkg-owncloud-commits] [php-sabredav] 04/07: Urls were not correctly encoded.

David Prévot taffit at moszumanska.debian.org
Tue Oct 27 19:44:09 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to tag 3.0.5
in repository php-sabredav.

commit 03fb8ed6d5656c68a7d87f8d07f8c3e15da4812c
Author: Evert Pot <me at evertpot.com>
Date:   Tue Sep 15 20:27:49 2015 +0200

    Urls were not correctly encoded.
---
 lib/DAV/Xml/Element/Response.php          |  2 +-
 lib/DAV/Xml/Property/Href.php             |  2 +-
 tests/Sabre/DAV/Xml/Property/HrefTest.php | 15 +++++++++++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/DAV/Xml/Element/Response.php b/lib/DAV/Xml/Element/Response.php
index a5cc1b3..e1f1e51 100644
--- a/lib/DAV/Xml/Element/Response.php
+++ b/lib/DAV/Xml/Element/Response.php
@@ -122,7 +122,7 @@ class Response implements Element {
         if ($status = $this->getHTTPStatus()) {
             $writer->writeElement('{DAV:}status', 'HTTP/1.1 ' . $status . ' ' . \Sabre\HTTP\Response::$statusCodes[$status]);
         }
-        $writer->writeElement('{DAV:}href', $writer->contextUri . $this->getHref());
+        $writer->writeElement('{DAV:}href', $writer->contextUri . \Sabre\HTTP\encodePath($this->getHref()));
         foreach ($this->getResponseProperties() as $status => $properties) {
 
             // Skipping empty lists
diff --git a/lib/DAV/Xml/Property/Href.php b/lib/DAV/Xml/Property/Href.php
index 246c965..ff831f8 100644
--- a/lib/DAV/Xml/Property/Href.php
+++ b/lib/DAV/Xml/Property/Href.php
@@ -105,7 +105,7 @@ class Href implements Element, HtmlOutput {
 
         foreach ($this->getHrefs() as $href) {
             if ($this->autoPrefix) {
-                $href = $writer->contextUri . $href;
+                $href = $writer->contextUri . \Sabre\HTTP\encodePath($href);
             }
             $writer->writeElement('{DAV:}href', $href);
         }
diff --git a/tests/Sabre/DAV/Xml/Property/HrefTest.php b/tests/Sabre/DAV/Xml/Property/HrefTest.php
index 83e9adb..13db316 100644
--- a/tests/Sabre/DAV/Xml/Property/HrefTest.php
+++ b/tests/Sabre/DAV/Xml/Property/HrefTest.php
@@ -30,6 +30,21 @@ class HrefTest extends XmlTest {
 ', $xml);
 
     }
+    function testSerializeSpace() {
+
+        $href = new Href('path alsopath');
+        $this->assertEquals('path alsopath', $href->getHref());
+
+        $this->contextUri = '/bla/';
+
+        $xml = $this->write(['{DAV:}anything' => $href]);
+
+        $this->assertXmlStringEqualsXmlString(
+'<?xml version="1.0"?>
+<d:anything xmlns:d="DAV:"><d:href>/bla/path%20alsopath</d:href></d:anything>
+', $xml);
+
+    }
 
     function testSerializeNoPrefix() {
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list