diff --git a/inc/CalDAVPrincipal.php b/inc/CalDAVPrincipal.php index 9c863373..5e6a1af9 100644 --- a/inc/CalDAVPrincipal.php +++ b/inc/CalDAVPrincipal.php @@ -99,21 +99,15 @@ class CalDAVPrincipal $this->{$k} = $v; } - $script = (preg_match('#/$#', $c->protocol_server_port_script) ? 'caldav.php' : ''); - $script = $c->protocol_server_port_script . $script; - if ( preg_match( '/ iCal 3\.0/', $_SERVER['HTTP_USER_AGENT'] ) ) { - $script = preg_replace('#^https?://[^/]+#', '', $script ); - } + $this->url = ConstructURL( "/".$this->username."/" ); +// $this->url = ConstructURL( "/__uuids__/" . $this->username . "/" ); - $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/", $script, $this->username); + $this->calendar_home_set = ConstructURL( "/".$this->username."/" ); $this->user_address_set = array( - 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), + ConstructURL( "/".$this->username."/" ), +// ConstructURL( "/~".$this->username."/" ), +// ConstructURL( "/__uuids__/".$this->username."/" ), ); $this->schedule_inbox_url = sprintf( "%s.in/", $this->calendar_home_set); $this->schedule_outbox_url = sprintf( "%s.out/", $this->calendar_home_set); diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index 0906ce57..2385c81d 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -72,15 +72,6 @@ class CalDAVRequest $this->user_agent = ((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "Probably Mulberry")); - /** - * In general we systematically return Absolute URI hrefs. Unfortunately some - * software doesn't expect this to happen (iCal, SOHO Organizer, ???) and so we - * need to hack around these programs. RFC4918 section 8.3 gives details. - */ - if ( preg_match( '/(iCal 3.0|SOHO Organizer|ChronosCalendarsService)/', $this->user_agent ) ) { - $c->protocol_server_port_script = preg_replace('#^(http|caldav)s?://[^/]+#', '', $c->protocol_server_port_script ); - } - /** * A variety of requests may set the "Depth" header to control recursion */ @@ -254,20 +245,6 @@ class CalDAVRequest } - /** - * Construct a URL from the supplied dav_name - * @param string $partial_path The part of the path after the script name - */ - function ConstructURL( $partial_path ) { - global $c; - - $url = $c->protocol_server_port_script . $partial_path; - $url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/' - $url = preg_replace('#^https?://[^/]+#', '', $url ); - return $url; - } - - /** * Permissions are controlled as follows: * 1. if the path is '/', the request has read privileges diff --git a/inc/always.php b/inc/always.php index 0cfbeb48..20057428 100644 --- a/inc/always.php +++ b/inc/always.php @@ -213,4 +213,24 @@ function getStatusMessage($status) { } +/** +* Construct a URL from the supplied dav_name +* @param string $partial_path The part of the path after the script name +*/ +function ConstructURL( $partial_path ) { + global $c; + + if ( ! isset($c->_url_script_path) ) { + $c->_url_script_path = (preg_match('#/$#', $c->protocol_server_port_script) ? 'caldav.php' : ''); + $c->_url_script_path = $c->protocol_server_port_script . $c->_url_script_path; + } + + $url = $c->_url_script_path . $partial_path; + $url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/' + $url = preg_replace('#^https?://[^/]+#', '', $url ); + return $url; +} + + + ?> \ No newline at end of file diff --git a/inc/always.php.in b/inc/always.php.in index 4b5f011e..85e7dbbd 100644 --- a/inc/always.php.in +++ b/inc/always.php.in @@ -213,4 +213,21 @@ function getStatusMessage($status) { } -?> \ No newline at end of file +/** +* Construct a URL from the supplied dav_name +* @param string $partial_path The part of the path after the script name +*/ +function ConstructURL( $partial_path ) { + global $c; + + if ( ! isset($c->_url_script_path) ) { + $c->_url_script_path = (preg_match('#/$#', $c->protocol_server_port_script) ? 'caldav.php' : ''); + $c->_url_script_path = $c->protocol_server_port_script . $c->_url_script_path; + } + + $url = $c->_url_script_path . $partial_path; + $url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/' + $url = preg_replace('#^https?://[^/]+#', '', $url ); + return $url; +} + diff --git a/inc/caldav-PROPFIND.php b/inc/caldav-PROPFIND.php index d6ec5f23..6fa2a19a 100644 --- a/inc/caldav-PROPFIND.php +++ b/inc/caldav-PROPFIND.php @@ -320,7 +320,7 @@ function collection_to_xml( $collection ) { $arbitrary_results = get_arbitrary_properties($collection->dav_name); $collection->properties = $arbitrary_results->found; - $url = $request->ConstructURL($collection->dav_name); + $url = ConstructURL($collection->dav_name); $resourcetypes = array( new XMLElement("collection") ); $contentlength = false; @@ -476,7 +476,7 @@ function item_to_xml( $item ) { $item->properties = get_arbitrary_properties($item->dav_name); - $url = $request->ConstructURL($item->dav_name); + $url = ConstructURL($item->dav_name); $prop = new XMLElement("prop"); $not_found = new XMLElement("prop"); diff --git a/inc/caldav-PROPPATCH.php b/inc/caldav-PROPPATCH.php index 3e9a21ca..b4a2c57c 100644 --- a/inc/caldav-PROPPATCH.php +++ b/inc/caldav-PROPPATCH.php @@ -195,7 +195,7 @@ if ( count($failure) > 0 ) { )); } - $url = $request->ConstructURL($request->path); + $url = ConstructURL($request->path); array_unshift( $failure, new XMLElement('href', $url ) ); $failure[] = new XMLElement('responsedescription', translate("Some properties were not able to be changed.") ); @@ -210,7 +210,7 @@ if ( count($failure) > 0 ) { $sql .= "COMMIT;"; $qry = new PgQuery( $sql ); if ( $qry->Exec() ) { - $url = $request->ConstructURL($request->path); + $url = ConstructURL($request->path); $href = new XMLElement('href', $url ); $desc = new XMLElement('responsedescription', translate("All requested changes were made.") ); diff --git a/inc/caldav-REPORT.php b/inc/caldav-REPORT.php index 4aee6056..e3c4c34a 100644 --- a/inc/caldav-REPORT.php +++ b/inc/caldav-REPORT.php @@ -96,7 +96,7 @@ function calendar_to_xml( $properties, $item ) { } } - $url = $request->ConstructURL($item->dav_name); + $url = ConstructURL($item->dav_name); $prop = new XMLElement("prop"); foreach( $properties AS $k => $v ) { diff --git a/testing/tests/regression-suite/840-Spec-PROPPATCH-1.result b/testing/tests/regression-suite/840-Spec-PROPPATCH-1.result index 20fdb480..24d760df 100644 --- a/testing/tests/regression-suite/840-Spec-PROPPATCH-1.result +++ b/testing/tests/regression-suite/840-Spec-PROPPATCH-1.result @@ -1,13 +1,13 @@ HTTP/1.1 200 OK Date: Dow, 01 Jan 2000 00:00:00 GMT DAV: 1, 2, access-control, calendar-access -Content-Length: 239 +Content-Length: 224 Content-Type: text/xml; charset="utf-8" - http://mycaldav/caldav.php/user1/home/ + /caldav.php/user1/home/ All requested changes were made.