diff --git a/phpgwapi/inc/class.groupdav_principals.inc.php b/phpgwapi/inc/class.groupdav_principals.inc.php index f4a8813a7b..d7cf315794 100644 --- a/phpgwapi/inc/class.groupdav_principals.inc.php +++ b/phpgwapi/inc/class.groupdav_principals.inc.php @@ -991,9 +991,31 @@ class groupdav_principals extends groupdav_handler $displayname = translation::convert($resource['name'], translation::charset(), 'utf-8'); - return ($is_location ? 'locations/' : 'resources/').$resource['res_id'].'-'.str_replace(array(' ','/',':','#','?'),'-',$displayname); + return ($is_location ? 'locations/' : 'resources/').$resource['res_id'].'-'. + preg_replace('/[^a-z0-9]+/i','-', self::to_ascii($resource['name'])); } + /** + * Transliterate utf-8 filename to ascii, eg. 'Äpfel' --> 'Aepfel' + * + * @param string $str + * @return string + */ + protected function to_ascii($str) + { + static $extra = array( + 'ß' => 'ss', + ); + $str = htmlentities($str,ENT_QUOTES,translation::charset()); + $str = str_replace(array_keys($extra),array_values($extra),$str); + $str = preg_replace('/&([aAuUoO])uml;/','\\1e',$str); // replace german umlauts with the letter plus one 'e' + $str = preg_replace('/&([a-zA-Z])(grave|acute|circ|ring|cedil|tilde|slash|uml);/','\\1',$str); // remove all types of acents + $str = preg_replace('/&([a-zA-Z]+|#[0-9]+|);/','',$str); // remove all other entities + + return $str; + } + + /** * Check if resource is a location *