diff --git a/inc/CalDAVPrincipal.php b/inc/CalDAVPrincipal.php index c5780984..9c863373 100644 --- a/inc/CalDAVPrincipal.php +++ b/inc/CalDAVPrincipal.php @@ -100,13 +100,18 @@ class CalDAVPrincipal } $script = (preg_match('#/$#', $c->protocol_server_port_script) ? 'caldav.php' : ''); - $this->url = sprintf( "%s%s/%s/", $c->protocol_server_port_script, $script, $this->username); + $script = $c->protocol_server_port_script . $script; + if ( preg_match( '/ iCal 3\.0/', $_SERVER['HTTP_USER_AGENT'] ) ) { + $script = preg_replace('#^https?://[^/]+#', '', $script ); + } + + $this->url = sprintf( "%s/%s/", $script, $this->username); // $this->url = sprintf( "%s%s/__uuids__/%s/", $c->protocol_server_port_script, $script, $this->username); - $this->calendar_home_set = sprintf( "%s%s/%s/", $c->protocol_server_port_script, $script, $this->username); + $this->calendar_home_set = sprintf( "%s/%s/", $script, $this->username); $this->user_address_set = array( - sprintf( "%s%s/%s/", $c->protocol_server_port_script, $script, $this->username), + sprintf( "%s/%s/", $script, $this->username), // sprintf( "%s%s/~%s/", $c->protocol_server_port_script, $script, $this->username), // sprintf( "%s%s/__uuids__/%s/", $c->protocol_server_port_script, $script, $this->username), ); diff --git a/inc/caldav-PROPFIND.php b/inc/caldav-PROPFIND.php index cb86923e..c40ffb94 100644 --- a/inc/caldav-PROPFIND.php +++ b/inc/caldav-PROPFIND.php @@ -216,9 +216,11 @@ function add_principal_properties( &$prop, &$not_found, &$denied ) { if ( isset($attribute_list['CALENDAR-USER-ADDRESS-SET'] ) ) { add_namespace("C", "urn:ietf:params:xml:ns:caldav"); - $email = new XMLElement('href', 'mailto:'.$request->principal->email ); - $calendar = new XMLElement('href', $request->principal->calendar_home_set ); - $prop->NewElement("C:calendar-user-address-set", array( $calendar, $email) ); + $addr_set = array(); + foreach( $request->principal->user_address_set AS $k => $v ) { + $addr_set[] = new XMLElement('href', $v ); + } + $prop->NewElement("C:calendar-user-address-set", $addr_set ); } } @@ -236,6 +238,10 @@ function collection_to_xml( $collection ) { $url = $c->protocol_server_port_script . $collection->dav_name; $url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/' + if ( preg_match( '/ iCal 3\.0/', $_SERVER['HTTP_USER_AGENT'] ) ) { + $url = preg_replace('#^https?://[^/]+#', '', $url ); + } + $resourcetypes = array( new XMLElement("collection") ); $contentlength = false;