From 0e40bd7cb532bbd49701df9ec29f16e6ec815054 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 10 Nov 2017 15:40:49 +0100 Subject: [PATCH] * CalDAV/CardDAV: fix encoding of control chars stalling iOS sync eg. \xb is not allowed in XML and caused iOS sync to stall, as it's XML parser fails use htmlspecialchars option ENT_XML1|ENT_DISALLOWED (PHP 5.4+) to ensure proper XML encoding --- api/src/WebDAV/Server.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/api/src/WebDAV/Server.php b/api/src/WebDAV/Server.php index 2860362573..e2cd11a9b1 100644 --- a/api/src/WebDAV/Server.php +++ b/api/src/WebDAV/Server.php @@ -1003,7 +1003,7 @@ class HTTP_WebDAV_Server } elseif (isset($prop['raw'])) { $val = $this->_prop_encode(''); } else { - $val = $this->_prop_encode(htmlspecialchars($prop['val'], ENT_NOQUOTES, 'utf-8')); + $val = $this->_prop_encode(htmlspecialchars($prop['val'], ENT_NOQUOTES|ENT_XML1|ENT_DISALLOWED, 'utf-8')); } echo ' <'.($this->crrnd?'':'D:')."$prop[name]$ns_defs>$val". 'crrnd?'':'D:')."$prop[name]>\n"; @@ -1049,7 +1049,7 @@ class HTTP_WebDAV_Server { foreach($subprop['val'] as $attr => $val) { - $vals .= ' '.$attr.'="'.htmlspecialchars($val, ENT_NOQUOTES, 'utf-8').'"'; + $vals .= ' '.$attr.'="'.htmlspecialchars($val, ENT_NOQUOTES|ENT_XML1|ENT_DISALLOWED, 'utf-8').'"'; } $vals .= '/>'; } @@ -1061,7 +1061,7 @@ class HTTP_WebDAV_Server $vals .= ''; } else { if($subprop['name'] == 'href') $subprop['val'] = $this->_urlencode($subprop['val']); - $vals .= htmlspecialchars($subprop['val'], ENT_NOQUOTES, 'utf-8'); + $vals .= htmlspecialchars($subprop['val'], ENT_NOQUOTES|ENT_XML1|ENT_DISALLOWED, 'utf-8'); } $vals .= ""; } @@ -1072,7 +1072,7 @@ class HTTP_WebDAV_Server { $val = ''; } else { - $val = htmlspecialchars($prop['val'], ENT_NOQUOTES, 'utf-8'); + $val = htmlspecialchars($prop['val'], ENT_NOQUOTES|ENT_XML1|ENT_DISALLOWED, 'utf-8'); } $val = $this->_prop_encode($val); // properties from namespaces != "DAV:" or without any namespace @@ -1199,7 +1199,7 @@ class HTTP_WebDAV_Server if ($responsedescr) { echo ' <'.($this->crrnd?'':'D:')."responsedescription>". - $this->_prop_encode(htmlspecialchars($responsedescr, ENT_NOQUOTES, 'utf-8')). + $this->_prop_encode(htmlspecialchars($responsedescr, ENT_NOQUOTES|ENT_XML1|ENT_DISALLOWED, 'utf-8')). 'crrnd?'':'D:')."responsedescription>\n"; } @@ -2794,7 +2794,7 @@ class HTTP_WebDAV_Server foreach($subprop as $attr => $val) { - $vals .= ' '.$attr.'="'.htmlspecialchars($val, ENT_NOQUOTES, 'utf-8').'"'; + $vals .= ' '.$attr.'="'.htmlspecialchars($val, ENT_NOQUOTES|ENT_XML1|ENT_DISALLOWED, 'utf-8').'"'; } $ret .= '<'.($prop['ns'] == $ns ? ($this->crrnd ? '' : $ns_hash[$ns].':') : $ns_hash[$prop['ns']].':').$prop['name'].