Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dav): don't crash subscription on invalid calendar object #48349

Closed
wants to merge 2 commits into from

Conversation

escoand
Copy link
Contributor

@escoand escoand commented Sep 25, 2024

Summary

I had two different problems here when subscribing to an external calendar.
When importing the same calendar these wrong objects get skipped.
But subscribing crashes at this point completely causing a partially imported calendar.

Nextcloud 29.0.7 is not affected.

{
  "reqId": "3KSLP9rLSEFtuslDIPBy",
  "level": 3,
  "time": "2024-09-25T10:04:22+00:00",
  "remoteAddr": "...",
  "user": "...",
  "app": "webdav",
  "method": "MKCOL",
  "url": "/remote.php/dav/calendars/...",
  "message": "The supplied iCalendar datetime value is incorrect: 20181202 00:00:00",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0",
  "version": "30.0.0.14",
  "exception": {
    "Exception": "Sabre\\VObject\\InvalidDataException",
    "Message": "The supplied iCalendar datetime value is incorrect: 20181202 00:00:00",
    "Code": 0,
    "Trace": /*...*/,
    "File": "/var/www/html/3rdparty/sabre/vobject/lib/DateTimeParser.php",
    "Line": 40,
    "message": "The supplied iCalendar datetime value is incorrect: 20181202 00:00:00",
    "exception": {},
    "CustomMessage": "The supplied iCalendar datetime value is incorrect: 20181202 00:00:00"
  }
}

and

{
  "reqId": "s9qaIfKbFDRspoMdIoXP",
  "level": 0,
  "time": "2024-09-25T09:56:50+00:00",
  "remoteAddr": "...",
  "user": "...",
  "app": "webdav",
  "method": "MKCOL",
  "url": "/remote.php/dav/calendars/...",
  "message": "This recurrence rule does not generate any valid instances",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36 Edg/129.0.0.0",
  "version": "30.0.0.14",
  "exception": {
    "Exception": "Sabre\\DAV\\Exception\\Forbidden",
    "Message": "This recurrence rule does not generate any valid instances",
    "Code": 0,
    "Trace": /*...*/,
    "File": "/var/www/html/apps/dav/lib/CalDAV/CalDavBackend.php",
    "Line": 3022,
    "message": "This recurrence rule does not generate any valid instances",
    "exception": {},
    "CustomMessage": "This recurrence rule does not generate any valid instances"
  }
}

TODO

  • ...

Checklist

@escoand escoand changed the title Don't crash subscription on invalid calendar object dix(dav): don't crash subscription on invalid calendar object Sep 25, 2024
@escoand escoand changed the title dix(dav): don't crash subscription on invalid calendar object fix(dav): don't crash subscription on invalid calendar object Sep 25, 2024
@kesselb
Copy link
Contributor

kesselb commented Sep 25, 2024

Thanks for your pull request 👍

@escoand escoand force-pushed the patch-2 branch 2 times, most recently from 3714b00 to 20b3d3d Compare September 26, 2024 13:25
@escoand escoand requested a review from kesselb September 26, 2024 13:27
@joshtrichards joshtrichards added bug 3. to review Waiting for reviews feature: caldav Related to CalDAV internals labels Sep 26, 2024
Copy link
Contributor

@SebastianKrupinski SebastianKrupinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@escoand only one issue you need to sign the PR.

@escoand
Copy link
Contributor Author

escoand commented Oct 1, 2024

@SebastianKrupinski done.

@kesselb
Copy link
Contributor

kesselb commented Oct 1, 2024

To fix the failing tests:

Index: apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php
--- a/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php	(revision 6be00432b75a80a246246883c5fa955ce803f3d8)
+++ b/apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php	(date 1727814673893)
@@ -302,7 +302,7 @@
 			->willThrowException($badRequestException);
 
 		$this->logger->expects(self::once())
-			->method('error')
+			->method('warning')
 			->with('Unable to create calendar object from subscription {subscriptionId}', ['exception' => $badRequestException, 'subscriptionId' => '42', 'source' => 'webcal://foo.bar/bla2']);
 
 		$refreshWebcalService->refreshSubscription('principals/users/testuser', 'sub123');

@SebastianKrupinski
Copy link
Contributor

@escoand... @kesselb is correct due to the change from a error to a warning our ci unit tests are failing...

1) OCA\DAV\Tests\unit\CalDAV\WebcalCaching\RefreshWebcalServiceTest::testRunCreateCalendarNoException with data set #0 ('BEGIN:VCALENDAR\r\nVERSION:2....AR\r\n', 'text/calendar;charset=utf8', 'BEGIN:VCALENDAR\r\nVERSION:2....AR\r\n')
Expectation failed for method name is "error" when invoked 1 time(s).
Method was expected to be called 1 times, actually called 0 times.

4) OCA\DAV\Tests\unit\CalDAV\WebcalCaching\RefreshWebcalServiceTest::testRunCreateCalendarBadRequest with data set #0 ('BEGIN:VCALENDAR\r\nVERSION:2....AR\r\n', 'text/calendar;charset=utf8', 'BEGIN:VCALENDAR\r\nVERSION:2....AR\r\n')
Expectation failed for method name is "error" when invoked 1 time(s).
Method was expected to be called 1 times, actually called 0 times.

Do you mind adjusting them? The file is "apps/dav/tests/unit/CalDAV/WebcalCaching/RefreshWebcalServiceTest.php" line 255 and 305. Both lines should be "->method('warning')"

Thanks! I would do it for you but its a bit of a pain because you are on a forked patch.

Signed-off-by: escoand <[email protected]>
@kesselb
Copy link
Contributor

kesselb commented Oct 2, 2024

Thanks again.

Cherry-picked your commits into #48519.

A part of our CI is skipped for forks because they don't work currently, but some of the skipped workflows are required to merge a pr 🙈

@SebastianKrupinski
Copy link
Contributor

@escoand Thank you for the PR. Its now been merged on the new PR that @kesselb linked. Unfortunately due to our CI forked PR's are a bit of a pain. I will now close this PR. Please feel free to contribute more!

@escoand escoand deleted the patch-2 branch October 2, 2024 13:14
Copy link
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug feature: caldav Related to CalDAV internals feedback-requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Failure on subscribing to a public Google calendar
4 participants