From 9b5554eac8bbd0548b45083a7397996f46a79eb2 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Tue, 17 Jan 2012 08:08:36 +1300 Subject: [PATCH 1/5] Make the 'append' option work. --- inc/ui/collection-edit.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/ui/collection-edit.php b/inc/ui/collection-edit.php index 9e672295..3e66e3ca 100644 --- a/inc/ui/collection-edit.php +++ b/inc/ui/collection-edit.php @@ -108,9 +108,10 @@ if ( $can_write_collection && $editor->IsSubmit() ) { $path = $editor->Value('dav_name'); $user_no = $editor->Value('user_no'); $username = $editor->Value('username'); + param_to_global('mode'); include_once('caldav-PUT-functions.php'); controlRequestContainer( $username, $user_no, $path, false, ($publicly_readable == 'on' ? true : false)); - import_collection( $ics, $user_no, $path, $session->user_no ); + import_collection( $ics, $user_no, $path, $session->user_no, ($mode == 'append') ); $c->messages[] = sprintf(translate('Calendar "%s" was loaded from file.'), $path); } else { From 3d55f164e2292a1ccf24fc803c738327d170d920 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Mon, 23 Jan 2012 09:43:33 +1300 Subject: [PATCH 2/5] Clean up content-type checking so it's not so noisy on null content. --- inc/CalDAVRequest.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index 20ac9e85..e0963fae 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -186,7 +186,7 @@ class CalDAVRequest if ( preg_match( '{^(\S+/\S+)\s*(;.*)?$}', $this->content_type, $matches ) ) { $this->content_type = $matches[1]; } - if ( isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > 7 ) { + if ( strlen($c->raw_post) > 0 ) { if ( $this->method == 'PROPFIND' || $this->method == 'REPORT' || $this->method == 'PROPPATCH' || $this->method == 'BIND' || $this->method == 'MKTICKET' || $this->method == 'ACL' ) { if ( !preg_match( '{^(text|application)/xml$}', $this->content_type ) ) { @dbg_error_log( "LOG request", 'Request is "%s" but client set content-type to "%s". Assuming they meant XML!', @@ -198,12 +198,8 @@ class CalDAVRequest $this->CoerceContentType(); } } - else if ( !preg_match( '{^(text|application)/xml$}', $this->content_type ) ) { - if ( $this->method == 'GET' || $this->method == 'HEAD' || $this->method == 'OPTIONS' || $this->method == 'MKCALENDAR' || $this->method == 'MKCOL' ) { - @dbg_error_log( "LOG request", '%s Request specified %s content type but none is present. Assuming null content-type.', - $request->method, $this->content_type ); - $this->content_type = 'text/plain'; - } + else { + $this->content_type = 'text/plain'; } $this->user_agent = ((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "Probably Mulberry")); From 8190f35257523d08d55b0309fc6fcd5d1d3a8052 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Mon, 23 Jan 2012 23:01:03 +1300 Subject: [PATCH 3/5] Allow specifying that this test will use Digest authentication. --- testing/dav_test | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testing/dav_test b/testing/dav_test index 5aa53201..3c3f3ef5 100755 --- a/testing/dav_test +++ b/testing/dav_test @@ -116,6 +116,11 @@ while( ) { @auth = (); }; + $line =~ /^\s*DIGEST\s*(#|$|=)/ && do { + push @arguments, "--digest"; + @auth = ( "--user", $1 ); + }; + $line =~ /^\s*AUTH\s*=\s*(\S.*)$/ && do { @auth = ( "--user", $1 ); }; From 46c8b64864d42960b36f4db169ca5c5e215b5377 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Mon, 23 Jan 2012 23:02:03 +1300 Subject: [PATCH 4/5] Fix problems calling import collection from external contexts. --- inc/caldav-PUT-functions.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php index 99581e17..f951b9fc 100644 --- a/inc/caldav-PUT-functions.php +++ b/inc/caldav-PUT-functions.php @@ -122,12 +122,15 @@ VALUES( :user_no, :parent_container, :dav_name, :dav_etag, :dav_displayname, TRU ); $qry->QDo( $sql, $params ); } - else if ( isset($public) && $collection->is_public == ($public?'t':'f') ) { + else if ( isset($public) ) { $collection = $qry->Fetch(); - $sql = 'UPDATE collection SET publicly_readable = :is_public::boolean WHERE collection_id = :collection_id'; - $params = array( ':is_public' => ($public?'t':'f'), ':collection_id' => $collection->collection_id ); - if ( ! $qry->QDo($sql,$params) ) { - rollback_on_error( $caldav_context, $user_no, $path ); + if ( empty($collection->is_public) ) $collection->is_public = 'f'; + if ( $collection->is_public == ($public?'t':'f') ) { + $sql = 'UPDATE collection SET publicly_readable = :is_public::boolean WHERE collection_id = :collection_id'; + $params = array( ':is_public' => ($public?'t':'f'), ':collection_id' => $collection->collection_id ); + if ( ! $qry->QDo($sql,$params) ) { + rollback_on_error( $caldav_context, $user_no, $path ); + } } } From 170bb90d09323854b8a8839e2628a09ba20d03a0 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Wed, 25 Jan 2012 08:13:11 +1300 Subject: [PATCH 5/5] Correct variable name used parsing RFC5545 duration. --- inc/RRule-v2.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/RRule-v2.php b/inc/RRule-v2.php index 72b0d1b3..aca9dfbc 100644 --- a/inc/RRule-v2.php +++ b/inc/RRule-v2.php @@ -115,7 +115,7 @@ class Rfc5545Duration { */ function asSeconds() { if ( !isset($this->epoch_seconds) ) { - if ( preg_match('{^(-?)P(\d+W)|((\d+D)?(T(\d+H)?(\d+M)?(\d+S)?)?)$}i', $subject, $matches) ) { + if ( preg_match('{^(-?)P(\d+W)|((\d+D)?(T(\d+H)?(\d+M)?(\d+S)?)?)$}i', $this->as_text, $matches) ) { if ( isset($matches[2]) ) $this->days = ($matches[2] * 7); else { if ( isset($matches[4]) ) $this->days = $matches[4];