nextcloud / calendar

📆 Calendar app for Nextcloud
https://apps.nextcloud.com/apps/calendar
GNU Affero General Public License v3.0
984 stars 241 forks source link

Adding a shared calendar via link fails if the calendar contains non- compliant VComponents #4430

Open miaulalala opened 2 years ago

miaulalala commented 2 years ago

Steps to reproduce

Add a google calendar via share link.

{
   "reqId":"WPDmb1ev23ZvuZRZGshW",
   "level":2,
   "time":"2022-08-18T12:45:55+00:00",
   "remoteAddr":"127.0.0.1",
   "user":"admin",
   "app":"dav",
   "method":"MKCOL",
   "url":"/remote.php/dav/calendars/admin/calendargooglecom-1",
   "message":"Subscription 2 could not be parsed",
   "userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
   "version":"25.0.0.5",
   "exception":{
      "Exception":"Sabre\\VObject\\ParseException",
      "Message":"This parser only supports VCARD and VCALENDAR files",
      "Code":0,
      "Trace":[
         {
            "file":"/var/www/nextcloud/3rdparty/sabre/vobject/lib/Parser/MimeDir.php",
            "line":90,
            "function":"parseDocument",
            "class":"Sabre\\VObject\\Parser\\MimeDir",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/3rdparty/sabre/vobject/lib/Reader.php",
            "line":47,
            "function":"parse",
            "class":"Sabre\\VObject\\Parser\\MimeDir",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php",
            "line":250,
            "function":"read",
            "class":"Sabre\\VObject\\Reader",
            "type":"::"
         },
         {
            "file":"/var/www/nextcloud/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php",
            "line":89,
            "function":"queryWebcalFeed",
            "class":"OCA\\DAV\\CalDAV\\WebcalCaching\\RefreshWebcalService",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/apps/dav/lib/Listener/SubscriptionListener.php",
            "line":63,
            "function":"refreshSubscription",
            "class":"OCA\\DAV\\CalDAV\\WebcalCaching\\RefreshWebcalService",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php",
            "line":87,
            "function":"handle",
            "class":"OCA\\DAV\\Listener\\SubscriptionListener",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
            "line":251,
            "function":"__invoke",
            "class":"OC\\EventDispatcher\\ServiceEventListener",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
            "line":73,
            "function":"callListeners",
            "class":"Symfony\\Component\\EventDispatcher\\EventDispatcher",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php",
            "line":88,
            "function":"dispatch",
            "class":"Symfony\\Component\\EventDispatcher\\EventDispatcher",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php",
            "line":100,
            "function":"dispatch",
            "class":"OC\\EventDispatcher\\EventDispatcher",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/apps/dav/lib/CalDAV/CalDavBackend.php",
            "line":2453,
            "function":"dispatchTyped",
            "class":"OC\\EventDispatcher\\EventDispatcher",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/CalDAV/CalendarHome.php",
            "line":249,
            "function":"createSubscription",
            "class":"OCA\\DAV\\CalDAV\\CalDavBackend",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/apps/dav/lib/CalDAV/CalendarHome.php",
            "line":93,
            "function":"createExtendedCollection",
            "class":"Sabre\\CalDAV\\CalendarHome",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line":1199,
            "function":"createExtendedCollection",
            "class":"OCA\\DAV\\CalDAV\\CalendarHome",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
            "line":560,
            "function":"createCollection",
            "class":"Sabre\\DAV\\Server",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
            "line":89,
            "function":"httpMkcol",
            "class":"Sabre\\DAV\\CorePlugin",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line":472,
            "function":"emit",
            "class":"Sabre\\DAV\\Server",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line":253,
            "function":"invokeMethod",
            "class":"Sabre\\DAV\\Server",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
            "line":321,
            "function":"start",
            "class":"Sabre\\DAV\\Server",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/apps/dav/lib/Server.php",
            "line":357,
            "function":"exec",
            "class":"Sabre\\DAV\\Server",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php",
            "line":35,
            "function":"exec",
            "class":"OCA\\DAV\\Server",
            "type":"->"
         },
         {
            "file":"/var/www/nextcloud/remote.php",
            "line":167,
            "args":[
               "/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"
            ],
            "function":"require_once"
         }
      ],
      "File":"/var/www/nextcloud/3rdparty/sabre/vobject/lib/Parser/MimeDir.php",
      "Line":163,
      "message":"Subscription 2 could not be parsed",
      "exception":{

      },
      "CustomMessage":"Subscription 2 could not be parsed"
   }
}

Expected behavior

The parser skips VComponents gracefully and still displays allowed VComponents VCARD and VCALENDAR.

OR

The calendar entry in the left sidebar in calendar shows an error icon that let's the user know there is an issue with this calendar.

Actual behaviour

The parser fails and doesn't show any events at all.

Calendar app version

No response

CalDAV-clients used

Web

Browser

No response

Client operating system

No response

Server operating system

No response

Web server

Apache

Database engine version

MySQL

PHP engine version

PHP 8.0

Nextcloud version

No response

Updated from an older installed version or fresh install

No response

List of activated apps

No response

Nextcloud configuration

No response

Web server error log

No response

Log file

No response

Browser log

No response

Additional info

No response

tcitworld commented 2 years ago

Not directly related, but can you share the non-compliant vcomponent in question?

miaulalala commented 2 years ago

Not directly related, but can you share the non-compliant vcomponent in question?

no i can't as I couldn't figure out which one it was :crying_cat_face:

Downloaded the entire calendar from Google but I didn't see anything obvious.

Components I had were (as an approximate structure)

VCALENDAR
    VTIMEZONE
       /DAYLIGHT
       /STANDARD
    VTIMEZONE
    VEVENT
       /VALARM
    VEVENT
VCALENDAR
tcitworld commented 2 years ago

It's likely an issue with a previous end of line rather than a new component start.

I'd say adding OPTION_IGNORE_INVALID_LINES to the parser (we already have OPTION_FORGIVING) would probably do it.

tcitworld commented 2 years ago

If you have the time, you can play with the debugger and set a breakpoint just before the exception to get the offending line.

miaulalala commented 2 years ago

Not yet, but I will hopefully look into it soon.