mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-30 03:24:47 +00:00
Merge branch 'master' of git+ssh://repo.or.cz/srv/git/davical
This commit is contained in:
commit
9e8e0e6898
@ -26,7 +26,7 @@ $request = new CalDAVRequest();
|
||||
|
||||
$code_file = sprintf( 'tz/%s.php', $action );
|
||||
if ( ! @include_once( $code_file ) ) {
|
||||
$request->PreconditionFailed(400, "supported-action", 'The action "'.$action.'" is not understood.' );
|
||||
$request->PreconditionFailed(400, "supported-action", 'The action "'.$action.'" is not understood.', 'urn:ietf:params:xml:ns:timezone-service' );
|
||||
}
|
||||
|
||||
$request->DoResponse( 500, translate("The application failed to understand that request.") );
|
||||
|
||||
@ -17,7 +17,7 @@ if ( ! isset ( $request ) ) {
|
||||
switch ( $request->path ) {
|
||||
case '/.well-known/caldav':
|
||||
case '/.well-known/carddav':
|
||||
header('Location: ' . ConstructURL('/',true) );
|
||||
header('Location: ' . $c->protocol_server_port . ConstructURL('/',true) );
|
||||
$request->DoResponse(301); // Moved permanently
|
||||
// does not return.
|
||||
case '/.well-known/timezone':
|
||||
@ -26,7 +26,7 @@ switch ( $request->path ) {
|
||||
$parameters .= ($parameters == '' ? '?' : '&' );
|
||||
$parameters .= $k.'='.rawurlencode($v);
|
||||
}
|
||||
header('Location: ' . str_replace('/caldav.php', '', ConstructURL('/tz.php',true)).$parameters );
|
||||
header('Location: ' . $c->protocol_server_port . str_replace('/caldav.php', '', ConstructURL('/tz.php',true)).$parameters );
|
||||
$request->DoResponse(301); // Moved permanently
|
||||
// does not return.
|
||||
}
|
||||
|
||||
@ -115,7 +115,33 @@ class CalDAVRequest
|
||||
if ( !isset($this->options['allow_by_email']) ) $this->options['allow_by_email'] = false;
|
||||
|
||||
if ( !isset($c->raw_post) ) $c->raw_post = file_get_contents( 'php://input');
|
||||
if ( isset($_SERVER['HTTP_CONTENT_ENCODING']) ) {
|
||||
@dbg_error_log('caldav', 'Content-Encoding: %s', $_SERVER['HTTP_CONTENT_ENCODING'] );
|
||||
switch( $_SERVER['HTTP_CONTENT_ENCODING'] ) {
|
||||
case 'gzip':
|
||||
$this->raw_post = gzdecode($c->raw_post);
|
||||
break;
|
||||
case 'deflate':
|
||||
$this->raw_post = gzinflate($c->raw_post);
|
||||
break;
|
||||
case 'compress':
|
||||
$this->raw_post = gzuncompress($c->raw_post);
|
||||
break;
|
||||
default:
|
||||
if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || isset($c->dbg['caldav'])) ) {
|
||||
$fh = fopen('/tmp/raw_post','w');
|
||||
if ( $fh ) {
|
||||
fwrite($fh,$request->raw_post);
|
||||
fclose($fh);
|
||||
}
|
||||
}
|
||||
$this->PreconditionFailed(402, 'content-encoding', 'This server does not presently support content encoded with "%s"', $_SERVER['HTTP_CONTENT_ENCODING']);
|
||||
}
|
||||
$c->raw_post = $this->raw_post;
|
||||
}
|
||||
else {
|
||||
$this->raw_post = $c->raw_post;
|
||||
}
|
||||
|
||||
if ( isset($debugging) && isset($_GET['method']) ) {
|
||||
$_SERVER['REQUEST_METHOD'] = $_GET['method'];
|
||||
@ -139,11 +165,6 @@ class CalDAVRequest
|
||||
}
|
||||
$this->user_agent = ((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "Probably Mulberry"));
|
||||
|
||||
if ( isset($_SERVER['HTTP_CONTENT_ENCODING']) ) {
|
||||
@dbg_error_log('caldav', 'Content-Encoding: %s', $_SERVER['HTTP_CONTENT_ENCODING']);
|
||||
$this->PreconditionFailed(402, 'content-encoding', 'This server does not presently support encoded content.');
|
||||
}
|
||||
|
||||
/**
|
||||
* A variety of requests may set the "Depth" header to control recursion
|
||||
*/
|
||||
@ -1091,11 +1112,11 @@ EOSQL;
|
||||
* @param string $precondition The namespaced precondition tag.
|
||||
* @param string $explanation An optional text explanation for the failure.
|
||||
*/
|
||||
function PreconditionFailed( $status, $precondition, $explanation = '') {
|
||||
function PreconditionFailed( $status, $precondition, $explanation = '', $xmlns='DAV:') {
|
||||
$xmldoc = sprintf('<?xml version="1.0" encoding="utf-8" ?>
|
||||
<error xmlns="DAV:">
|
||||
<error xmlns="%s">
|
||||
<%s/>%s
|
||||
</error>', str_replace('DAV::', '', $precondition), $explanation );
|
||||
</error>', $xmlns, str_replace($xmlns.':', '', $precondition), $explanation );
|
||||
|
||||
$this->DoResponse( $status, $xmldoc, 'text/xml; charset="utf-8"' );
|
||||
exit(0); // Unecessary, but might clarify things
|
||||
|
||||
@ -14,7 +14,7 @@ require_once('RRule-v2.php');
|
||||
|
||||
if ( empty($format) ) $format = 'text/calendar';
|
||||
if ( $format != 'text/calendar' ) {
|
||||
$request->PreconditionFailed(403, 'supported-format', 'This server currently only supports text/calendar format.');
|
||||
$request->PreconditionFailed(403, 'supported-format', 'This server currently only supports text/calendar format.', 'urn:ietf:params:xml:ns:timezone-service' );
|
||||
}
|
||||
|
||||
if ( empty($start) ) $start = sprintf( '%04d-01-01', date('Y'));
|
||||
|
||||
@ -13,7 +13,7 @@ require_once('vCalendar.php');
|
||||
|
||||
if ( empty($format) ) $format = 'text/calendar';
|
||||
if ( $format != 'text/calendar' ) {
|
||||
$request->PreconditionFailed(403, 'supported-format', 'This server currently only supports text/calendar format.');
|
||||
$request->PreconditionFailed(403, 'supported-format', 'This server currently only supports text/calendar format.', 'urn:ietf:params:xml:ns:timezone-service');
|
||||
}
|
||||
|
||||
$sql = 'SELECT our_tzno, tzid, active, olson_name, vtimezone, etag, ';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user