From a41f8d384498bd5fff639a6699e09339d6c104b2 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 30 Nov 2024 21:13:46 +1300 Subject: [PATCH 1/4] Fix typo --- inc/caldav-client-v2.php | 2 +- inc/caldav-client.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/caldav-client-v2.php b/inc/caldav-client-v2.php index d280eb09..8488b418 100644 --- a/inc/caldav-client-v2.php +++ b/inc/caldav-client-v2.php @@ -70,7 +70,7 @@ class CalDAVClient { protected $calendar_urls; /** - * The useragent which is send to the caldav server + * The useragent which is sent to the caldav server * * @var string */ diff --git a/inc/caldav-client.php b/inc/caldav-client.php index b32c5c91..31e1ec03 100644 --- a/inc/caldav-client.php +++ b/inc/caldav-client.php @@ -26,7 +26,7 @@ class CalDAVClient { var $base_url, $user, $pass, $calendar, $entry, $protocol, $server, $port; /** - * The useragent which is send to the caldav server + * The useragent which is sent to the caldav server * * @var string */ From 8be9efe348303e94ffb0474ae56a65cccabc1f66 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Fri, 13 Dec 2024 23:03:07 +1300 Subject: [PATCH 2/4] Fix DAV:current-user-principal for iPhone devices iPhone devices incorrectly implement DAV:current-user-principal from RFC 5397. They assume that current-user-principal is the href for the resource being queried. The RFC says it should be the current resource. See: https://gitlab.com/davical-project/davical/-/issues/335 --- inc/DAVResource.php | 9 +++- .../2800-iPhone-shared-addresses.result | 27 ++++++++++ .../2800-iPhone-shared-addresses.test | 44 ++++++++++++++++ .../2801-iPhone-shared-addresses.result | 50 +++++++++++++++++++ .../2801-iPhone-shared-addresses.test | 16 ++++++ .../2802-correct-shared-addresses.result | 50 +++++++++++++++++++ .../2802-correct-shared-addresses.test | 16 ++++++ 7 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 testing/tests/regression-suite/2800-iPhone-shared-addresses.result create mode 100644 testing/tests/regression-suite/2800-iPhone-shared-addresses.test create mode 100644 testing/tests/regression-suite/2801-iPhone-shared-addresses.result create mode 100644 testing/tests/regression-suite/2801-iPhone-shared-addresses.test create mode 100644 testing/tests/regression-suite/2802-correct-shared-addresses.result create mode 100644 testing/tests/regression-suite/2802-correct-shared-addresses.test diff --git a/inc/DAVResource.php b/inc/DAVResource.php index a6509112..343b150f 100644 --- a/inc/DAVResource.php +++ b/inc/DAVResource.php @@ -1881,8 +1881,15 @@ EOQRY; $prop->NewElement( 'principal-collection-set', $reply->href( ConstructURL('/') ) ); break; + # iPhone devices incorrectly implement DAV:current-user-principal from + # RFC 5397. They assume that current-user-principal is the href for the + # resource being queried. The RFC says it should be the current resource. + # See: https://gitlab.com/davical-project/davical/-/issues/335 case 'DAV::current-user-principal': - $prop->NewElement('current-user-principal', $reply->href( ConstructURL(DeconstructURL($session->principal->url())) ) ); + if ( preg_match('/iPhone/', $_SERVER['HTTP_USER_AGENT']) ) + $prop->NewElement('current-user-principal', $reply->href( ConstructURL(DeconstructURL($request->principal->url())) ) ); + else + $prop->NewElement('current-user-principal', $reply->href( ConstructURL(DeconstructURL($session->principal->url())) ) ); break; case 'SOME-DENIED-PROPERTY': /** indicating the style for future expansion */ diff --git a/testing/tests/regression-suite/2800-iPhone-shared-addresses.result b/testing/tests/regression-suite/2800-iPhone-shared-addresses.result new file mode 100644 index 00000000..273efd0f --- /dev/null +++ b/testing/tests/regression-suite/2800-iPhone-shared-addresses.result @@ -0,0 +1,27 @@ +HTTP/1.1 200 OK +Date: Dow, 01 Jan 2000 00:00:00 GMT +DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule +DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy +Content-Length: 0 +Content-Type: text/plain; charset="utf-8" + + +SQL Query 1 Result: + by_collection: >NULL< + by_principal: >1002< + displayname: >User 4< + privileges: >000000000001001000100001< + to_principal: >1005< + + by_collection: >NULL< + by_principal: >1002< + displayname: >Assistant 1< + privileges: >000000000001001011000111< + to_principal: >1009< + + by_collection: >NULL< + by_principal: >1002< + displayname: >Team for Client1< + privileges: >000000000001001000000001< + to_principal: >1013< + diff --git a/testing/tests/regression-suite/2800-iPhone-shared-addresses.test b/testing/tests/regression-suite/2800-iPhone-shared-addresses.test new file mode 100644 index 00000000..69fc646c --- /dev/null +++ b/testing/tests/regression-suite/2800-iPhone-shared-addresses.test @@ -0,0 +1,44 @@ +# Test for iPhone devices which incorrectly implement +# DAV:current-user-principal from RFC 5397. They assume that +# current-user-principal is the href for the resource being queried. The +# RFC says it should be the current resource. #Sigh. +# +# See: https://gitlab.com/davical-project/davical/-/issues/335 +# +# Ensure that user4 can access user1's address book. +TYPE=ACL +HEADER=User-Agent: RFC3744 Spec Tests +HEADER=Content-Type: text/xml; charset="UTF-8" +HEAD + +BEGINDATA + + + + + /caldav.php/user4/ + + + + + + + + + + + + + +ENDDATA + +URL=http://regression.host/caldav.php/user1/ + +QUERY +SELECT by_principal, by_collection, privileges, p_to.displayname, to_principal + FROM grants JOIN dav_principal p_to ON (to_principal=principal_id) + LEFT JOIN collection ON (by_collection=collection.collection_id) + LEFT JOIN dav_principal p_by ON (by_principal=p_by.principal_id) + WHERE p_by.dav_name = '/user1/' + ORDER BY by_principal, to_principal +ENDQUERY diff --git a/testing/tests/regression-suite/2801-iPhone-shared-addresses.result b/testing/tests/regression-suite/2801-iPhone-shared-addresses.result new file mode 100644 index 00000000..be6afe76 --- /dev/null +++ b/testing/tests/regression-suite/2801-iPhone-shared-addresses.result @@ -0,0 +1,50 @@ +HTTP/1.1 207 Multi-Status +Date: Dow, 01 Jan 2000 00:00:00 GMT +Content-Location: /caldav.php/user1/addresses/ +DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule +DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy +ETag: "43765875e20eef2d841725645b2f3c95" +Content-Length: 1129 +Content-Type: text/xml; charset="utf-8" + + + + + /caldav.php/user1/addresses/ + + + httpd/unix-directory + + + + + user1 addresses + Sun, 15 Mar 1998 12:00:00 GMT + 19570725T120000Z + + + + + + + + + + + + + /caldav.php/user1/ + + + /caldav.php/user1/ + + 6550000 + + + + + HTTP/1.1 200 OK + + + + diff --git a/testing/tests/regression-suite/2801-iPhone-shared-addresses.test b/testing/tests/regression-suite/2801-iPhone-shared-addresses.test new file mode 100644 index 00000000..2e778c8e --- /dev/null +++ b/testing/tests/regression-suite/2801-iPhone-shared-addresses.test @@ -0,0 +1,16 @@ +# Test for iPhone devices which incorrectly implement +# DAV:current-user-principal from RFC 5397. They assume that +# current-user-principal is the href for the resource being queried. The +# RFC says it should be the current resource. #Sigh. +# +# See: https://gitlab.com/davical-project/davical/-/issues/335 +# +# Ensure that user4 has user1 as the current-user-principal as we're an +# 'iPhone'. +TYPE=PROPFIND +AUTH=user4:user4 +HEADER=Content-Type: text/xml; charset="UTF-8" +HEADER=User-Agent: DAVKit/4.0 (728.3); iCalendar/1 (34); iPhone/3.0 +HEAD + +URL=http://regression.host/caldav.php/user1/addresses diff --git a/testing/tests/regression-suite/2802-correct-shared-addresses.result b/testing/tests/regression-suite/2802-correct-shared-addresses.result new file mode 100644 index 00000000..15aaaaf8 --- /dev/null +++ b/testing/tests/regression-suite/2802-correct-shared-addresses.result @@ -0,0 +1,50 @@ +HTTP/1.1 207 Multi-Status +Date: Dow, 01 Jan 2000 00:00:00 GMT +Content-Location: /caldav.php/user1/addresses/ +DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule +DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy +ETag: "3f9506c10fe5b434f966d4c82f026c40" +Content-Length: 1129 +Content-Type: text/xml; charset="utf-8" + + + + + /caldav.php/user1/addresses/ + + + httpd/unix-directory + + + + + user1 addresses + Sun, 15 Mar 1998 12:00:00 GMT + 19570725T120000Z + + + + + + + + + + + + + /caldav.php/user1/ + + + /caldav.php/user4/ + + 6550000 + + + + + HTTP/1.1 200 OK + + + + diff --git a/testing/tests/regression-suite/2802-correct-shared-addresses.test b/testing/tests/regression-suite/2802-correct-shared-addresses.test new file mode 100644 index 00000000..419d9630 --- /dev/null +++ b/testing/tests/regression-suite/2802-correct-shared-addresses.test @@ -0,0 +1,16 @@ +# Test for iPhone devices which incorrectly implement +# DAV:current-user-principal from RFC 5397. They assume that +# current-user-principal is the href for the resource being queried. The +# RFC says it should be the current resource. #Sigh. +# +# See: https://gitlab.com/davical-project/davical/-/issues/335 +# +# Ensure that user4 has user4 as the current-user-principal as we're not an +# 'iPhone'. +TYPE=PROPFIND +AUTH=user4:user4 +HEADER=Content-Type: text/xml; charset="UTF-8" +HEADER=User-Agent: Evolution/1.8.1 +HEAD + +URL=http://regression.host/caldav.php/user1/addresses From 744edb12044c42ed89d2ac178e51fff2e308c9bb Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Fri, 13 Dec 2024 23:36:16 +1300 Subject: [PATCH 3/4] We need rst2pdf installed for testing Looks like this has been removed as a dependency from a package. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd138d67..d6c1a184 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,7 @@ build: script: - apt-get -y update - bash -c 'mkdir -p /usr/share/man/man{0..10}' - - apt-get -y install build-essential devscripts fakeroot dh-exec jdupes doxygen graphviz php-cli phpunit + - apt-get -y install build-essential devscripts fakeroot dh-exec jdupes doxygen graphviz php-cli phpunit rst2pdf - mv debian/changelog debian/changelog.old - > cat @@ -82,7 +82,7 @@ build_bullseye_latestphp: script: - apt-get -y update - bash -c 'mkdir -p /usr/share/man/man{0..10}' - - apt-get -y install build-essential devscripts fakeroot dh-exec jdupes doxygen graphviz + - apt-get -y install build-essential devscripts fakeroot dh-exec jdupes doxygen graphviz rst2pdf - mv debian/changelog debian/changelog.old - > cat From f36065a49ba49532336de0da21a561dafd52d0f2 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 14 Dec 2024 00:13:27 +1300 Subject: [PATCH 4/4] Fix deprecation warning for explicit nullable type. --- inc/DAVResource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/DAVResource.php b/inc/DAVResource.php index 343b150f..78c7d7a0 100644 --- a/inc/DAVResource.php +++ b/inc/DAVResource.php @@ -173,7 +173,7 @@ class DAVResource * field of the resource is populated with the given data, so it does not need * to be queried again later */ - function __construct( $parameters = null, DAVResource $prefetched_collection = null ) { + function __construct( $parameters = null, ?DAVResource $prefetched_collection = null ) { $this->exists = null; $this->bound_from = null; $this->dav_name = null;