diff --git a/egw-pear/HTTP/WebDAV/Server.php b/egw-pear/HTTP/WebDAV/Server.php index ea9a427661..94dd2170a6 100644 --- a/egw-pear/HTTP/WebDAV/Server.php +++ b/egw-pear/HTTP/WebDAV/Server.php @@ -600,8 +600,14 @@ class HTTP_WebDAV_Server echo "\n"; echo "\n"; + // using an ArrayIterator to prevent foreach from copying the array, + // as we cant loop by reference, when an iterator is given in $files['files'] + if (is_array($files['files'])) + { + $files['files'] = new ArrayIterator($files['files']); + } // now we loop over all returned file entries - foreach ($files["files"] as &$file) { + foreach ($files['files'] as $file) { // collect namespaces here $ns_hash = array(); @@ -687,7 +693,8 @@ class HTTP_WebDAV_Server = $this->mkprop("DAV:", "lockdiscovery", $this->lockdiscovery($file['path'])); - } else { + // only collect $file['noprops'] if we have NO Brief: t HTTP Header + } elseif (!isset($this->_SERVER['HTTP_BRIEF']) || $this->_SERVER['HTTP_BRIEF'] != 't') { // add empty value for this property $file["noprops"][] = $this->mkprop($reqprop["xmlns"], $reqprop["name"], ""); @@ -750,36 +757,6 @@ class HTTP_WebDAV_Server . gmdate("D, d M Y H:i:s ", $prop['val']) . "GMT\n"; break; - case "resourcetype": - if (!is_array($prop['val'])) { - echo " \n"; - } else { // multiple resourcetypes from different namespaces as required by GroupDAV - $vals = $extra_ns = ''; - foreach($prop['val'] as $subprop) - { - if ($subprop['ns'] && $subprop['ns'] != 'DAV:') { - // register property namespace if not known yet - if (!isset($ns_hash[$subprop['ns']])) { - $ns_name = "ns".(count($ns_hash) + 1); - $ns_hash[$subprop['ns']] = $ns_name; - } else { - $ns_name = $ns_hash[$subprop['ns']]; - } - if (strchr($extra_ns,$extra=' xmlns:'.$ns_name.'="'.$subprop['ns'].'"') === false) { - $extra_ns .= $extra; - } - $ns_name .= ':'; - } elseif ($subprop['ns'] == 'DAV:') { - $ns_name = 'D:'; - } else { - $ns_name = ''; - } - $vals .= "<$ns_name$subprop[val]/>"; - } - echo " $vals\n"; - //error_log("resourcetype: $vals"); - } - break; case "supportedlock": echo " $prop[val]\n"; break; @@ -789,10 +766,11 @@ class HTTP_WebDAV_Server echo " \n"; break; default: - if (is_array($prop['val'])) error_log($file['path'].': '.$prop['name'].'='.array2string($prop['val'])); - echo " " - . $this->_prop_encode(htmlspecialchars($prop['val'])) - . "\n"; + echo " ". + (is_array($prop['val']) ? + $this->_hierarchical_prop_encode($prop['val']) : + $this->_prop_encode(htmlspecialchars($prop['val']))). + "\n"; break; } } else { @@ -2076,6 +2054,15 @@ class HTTP_WebDAV_Server */ function _urlencode($url) { + // cadaver (and probably all neon using agents) need a more complete url encoding + // otherwise special chars like "$,()'" in filenames do NOT work + if (strpos($_SERVER['HTTP_USER_AGENT'],'neon') !== false) + { + return strtr(rawurlencode($url),array( + '%2F' => '/', + '%3A' => ':', + )); + } //error_log( __METHOD__."\n" .print_r($url,true)); return strtr($url, array(" "=>"%20", "&"=>"%26", @@ -2098,6 +2085,45 @@ class HTTP_WebDAV_Server return urldecode($path); } + /** + * Encode a hierarchical properties like: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * @param array $props + * @return string + */ + function _hierarchical_prop_encode(array $props) + { + //error_log(__METHOD__.'('.array2string($props).')'); + if (isset($props['name'])) $props = array($props); + + $ret = ''; + foreach($props as $prop) + { + $ret .= '<'.$prop['name']. + ($prop['ns'] != 'DAV:' ? ' xmlns="'.$prop['ns'].'"' : ''). + (empty($prop['val']) ? ' />' : '>'. + (is_array($prop['val']) ? + $this->_hierarchical_prop_encode($prop['val']) : + $this->_prop_encode($prop['val'])). + ''); + } + //error_log(__METHOD__.'('.array2string($props).') = '.array2string($ret)); + return $ret; + } + /** * UTF-8 encode property values if not already done so * @@ -2117,7 +2143,7 @@ class HTTP_WebDAV_Server case "iso-8859-15": case "latin-1": default: - //error_log( __METHOD__."utf8 encode\n" .print_r(utf8_encode($text),true)); + error_log( __METHOD__."utf8 encode\n" .print_r(utf8_encode($text),true)); return utf8_encode($text); } }