mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-31 18:46:02 +00:00
Test whether a URL without a trailing '/' is actually a collection.
This commit is contained in:
parent
6650e848e2
commit
1740c66491
@ -100,6 +100,21 @@ class CalDAVRequest
|
||||
$this->DoResponse( 400, translate("The calendar path contains illegal characters.") );
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC2518, 5.2: URL pointing to a collection SHOULD end in '/', and if it does not then
|
||||
* we SHOULD return a Content-location header with the correction...
|
||||
*/
|
||||
if ( !preg_match( '#/$#', $this->path ) ) {
|
||||
dbg_error_log( "caldav", "Checking whether path might be a collection" );
|
||||
$qry = new PgQuery( "SELECT count(1) AS is_collection FROM collection WHERE dav_name = ?;", $this->path . '/');
|
||||
if ( $qry->Exec('caldav') && $qry->rows == 1 && ($row = $qry->Fetch()) && $row->is_collection == 1 ) {
|
||||
dbg_error_log( "caldav", "Path is actually a collection - sending Content-Location header." );
|
||||
$this->path .= '/';
|
||||
header( "Content-Location: $this->path" );
|
||||
$this->_is_collection = true;
|
||||
}
|
||||
}
|
||||
|
||||
$path_split = preg_split('#/+#', $this->path );
|
||||
$this->permissions = array();
|
||||
if ( !isset($path_split[1]) || $path_split[1] == '' ) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user