diff --git a/config/example-config.php b/config/example-config.php index db47967f..46ec87b4 100644 --- a/config/example-config.php +++ b/config/example-config.php @@ -42,7 +42,7 @@ $c->pg_connect[] = "dbname=davical user=davical_app"; * will be read-only. Any changes to them must be applied via CalDAV. * * You may want to set this to false during your initial setup to make it -* easier for people to PUT whole calendars as part of the conversion of +* easier for people to PUT whole calendars or addressbooks as part of migrating * their data. After this, it is recommended to turn it off so that clients * which have been misconfigured are readily identifiable. * Default: true diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php index 9cdeedef..cd40b82a 100644 --- a/inc/caldav-PUT-functions.php +++ b/inc/caldav-PUT-functions.php @@ -666,9 +666,9 @@ function import_collection( $import_content, $user_no, $path, $caldav_context, $ } if ( preg_match( '{^begin:(vcard|vcalendar)}i', $import_content, $matches) ) { - if ( $matches[1] == 'VCARD' ) + if ( strtoupper($matches[1]) == 'VCARD' ) import_addressbook_collection( $import_content, $user_no, $path, $caldav_context, $appending ); - elseif ( $matches[1] == 'VCALENDAR' ) + elseif ( strtoupper($matches[1]) == 'VCALENDAR' ) import_calendar_collection( $import_content, $user_no, $path, $caldav_context, $appending ); // Uncache anything to do with the collection diff --git a/testing/tests/carddav/2001-PUT-fail.result b/testing/tests/carddav/2001-PUT-fail.result index ade14d0a..53a4ee8f 100644 --- a/testing/tests/carddav/2001-PUT-fail.result +++ b/testing/tests/carddav/2001-PUT-fail.result @@ -1,8 +1,11 @@ -HTTP/1.1 403 Forbidden +HTTP/1.1 409 Conflict 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: 92 -Content-Type: text/plain; charset="utf-8" +Content-Length: 137 +Content-Type: text/xml; charset="utf-8" -PUT on a collection is only allowed for text/vcard content against an addressbook collection + + + The destination collection does not exist + diff --git a/testing/tests/carddav/2001-PUT-fail.test b/testing/tests/carddav/2001-PUT-fail.test index 72ca4e6e..578d541d 100644 --- a/testing/tests/carddav/2001-PUT-fail.test +++ b/testing/tests/carddav/2001-PUT-fail.test @@ -1,8 +1,8 @@ # -# PUT a VCARD record into an addressbook +# PUT a VCARD record into a non-existing addressbook # TYPE=PUT -URL=http://regression.host/caldav.php/user1/addressbook/ +URL=http://regression.host/caldav.php/user1/addressbook1/kelly.vcf HEADER=User-Agent: DAViCalTester/public HEADER=Content-Type: text/vcard; charset=utf-8 @@ -27,7 +27,7 @@ ENDDATA QUERY SELECT caldav_data.dav_name, caldav_data.dav_etag, fn, n FROM caldav_data JOIN addressbook_resource USING(dav_id) - WHERE caldav_data.dav_name ~ '/user1/addressbook/' + WHERE caldav_data.dav_name ~ '/user1/addressbook1/' ENDQUERY diff --git a/testing/tests/carddav/2040-PUT-addressbook.result b/testing/tests/carddav/2040-PUT-addressbook.result new file mode 100644 index 00000000..3a6fbc0c --- /dev/null +++ b/testing/tests/carddav/2040-PUT-addressbook.result @@ -0,0 +1,16 @@ +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" + + + count: >3< + + fn: >Fred Weasley< + + fn: >Donald Kelly< + + fn: >George Weasley< + diff --git a/testing/tests/carddav/2040-PUT-addressbook.test b/testing/tests/carddav/2040-PUT-addressbook.test new file mode 100644 index 00000000..0e6fa038 --- /dev/null +++ b/testing/tests/carddav/2040-PUT-addressbook.test @@ -0,0 +1,53 @@ +# +# PUT three VCARD records into an addressbook +# +TYPE=PUT +URL=http://regression.host/caldav.php/user1/addresses/ + +HEADER=User-Agent: DAViCalTester/public +HEADER=Content-Type: text/vcard; charset=utf-8 +HEAD + +BEGINDATA +begin:vcard +fn:Donald Kelly +n:Kelly;Donald +org:Esposo Designs Ltd +adr:Newtown;;25 Rintoul St;Wellington;;;New Zealand +email;internet:donald@example.co.nz +title:Proprietor +tel;work:+64 4 347 4747 +tel;cell:+64 2 1234-4321 +x-mozilla-html:TRUE +url:www.example.co.nz +version:2.1 +end:vcard +BEGIN:VCARD +VERSION:2.1 +N:Weasley;George +FN:George Weasley +EMAIL;PREF;INTERNET:gweasley@example.org +REV:20030909T234634Z +END:VCARD +BEGIN:VCARD +VERSION:2.1 +N:Weasley;Fred +FN:Fred Weasley +EMAIL;PREF;INTERNET:fweasley@example.org +REV:20030909T234507Z +END:VCARD +ENDDATA + +QUERY +SELECT COUNT(caldav_data.dav_name) + FROM caldav_data + WHERE caldav_data.dav_name ~ '/user1/addresses/' +ENDQUERY + +QUERY +SELECT fn + FROM caldav_data JOIN addressbook_resource USING(dav_id) + WHERE caldav_data.dav_name ~ '/user1/addresses/' +ENDQUERY + +