From b301a36aca852b62c390eb6108b1a43a83dd4646 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Fri, 13 May 2011 14:53:43 +1200 Subject: [PATCH] When sync-collection is asked for data, only return it if < 50 rows. The resource data element is not *actually* allowed, per the spec, but some clients do use it, and some servers do support it. In the case of an initial sync which requests it we don't want to send down a huge response to an ill-considered client. --- inc/DAVResource.php | 1 + inc/caldav-REPORT-sync-collection.php | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/inc/DAVResource.php b/inc/DAVResource.php index 5ca4f3f0..9316f361 100644 --- a/inc/DAVResource.php +++ b/inc/DAVResource.php @@ -1597,6 +1597,7 @@ EOQRY; case 'urn:ietf:params:xml:ns:carddav:address-data': case 'urn:ietf:params:xml:ns:caldav:calendar-data': if ( $this->_is_collection ) return false; + if ( !isset($c->sync_resource_data_ok) || $c->sync_resource_data_ok == false ) return false; if ( !isset($this->resource) ) $this->FetchResource(); $reply->NSElement($prop, $tag, $this->resource->caldav_data ); break; diff --git a/inc/caldav-REPORT-sync-collection.php b/inc/caldav-REPORT-sync-collection.php index 19f0820b..be6fbeb0 100644 --- a/inc/caldav-REPORT-sync-collection.php +++ b/inc/caldav-REPORT-sync-collection.php @@ -91,6 +91,10 @@ EOSQL; $first_status = 0; if ( $qry->Exec("REPORT",__LINE__,__FILE__) ) { + if ( $qry->rows() > 50 ) { + // If there are more than 50 rows to send we should not send full data in response ... + $c->sync_resource_data_ok = false; + } while( $object = $qry->Fetch() ) { if ( $object->dav_name == $last_dav_name ) { /** The complex case: this is the second or subsequent for this dav_id */