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(caldav): convert iMip recipient name to a string #36898

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

st3iny
Copy link
Member

@st3iny st3iny commented Feb 28, 2023

Summary

The recipient name is expected to be a string or null. Before this PR, it was a Sabre\VObject\Parameter so we need to convert it to a string.

The \Sabre\VObject\ITip\Message::$recipientName property should be string or null and is wrongly annotated upstream (in Sabre).

    /**
     * The name of the recipient. This is usually populated with the CN
     * parameter from the ATTENDEE or ORGANIZER property, if it's available.
     *
     * @var string|null
     */
    public $recipientName;

TODO

Checklist

@st3iny st3iny added bug 3. to review Waiting for reviews feature: caldav Related to CalDAV internals labels Feb 28, 2023
@st3iny st3iny self-assigned this Feb 28, 2023
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php Outdated Show resolved Hide resolved
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
@st3iny st3iny force-pushed the fix/36897/recipient-name-string branch from d34869f to 2c0d89e Compare February 28, 2023 14:21
@@ -173,7 +173,7 @@
$iTipMessage->scheduleStatus = '5.0; EMail delivery failed';
return;
}
$recipientName = $iTipMessage->recipientName ?: null;
$recipientName = $iTipMessage->recipientName ? (string)$iTipMessage->recipientName : null;

Check notice

Code scanning / Psalm

RedundantCastGivenDocblockType

Redundant cast to string given docblock-provided type
@nickvergessen
Copy link
Member

Applied on our instance

@st3iny st3iny merged commit 7c477d4 into master Feb 28, 2023
@st3iny st3iny deleted the fix/36897/recipient-name-string branch February 28, 2023 18:10
@nickvergessen
Copy link
Member

nickvergessen commented Mar 1, 2023

Now errors a bit further down, as it assumes $this->userId would be set.

{
  "reqId": "aYk6tC4vpMagsgJaEjAU",
  "level": 3,
  "time": "2023-03-01T08:04:12+00:00",
  "remoteAddr": "2a02:…",
  "user": "…",
  "app": "webdav",
  "method": "PUT",
  "url": "/remote.php/dav/calendars/…/…/cf33c5ec-….ics",
  "message": "OC\\User\\Manager::getDisplayName(): Argument #1 ($uid) must be of type string, null given, called in /var/www/cloud.nextcloud.com/nextcloud/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php on line 213",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0",
  "version": "26.0.0.7",
  "exception": {
    "Exception": "TypeError",
    "Message": "OC\\User\\Manager::getDisplayName(): Argument #1 ($uid) must be of type string, null given, called in /var/www/cloud.nextcloud.com/nextcloud/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php on line 213",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php",
        "line": 213,
        "function": "getDisplayName",
        "class": "OC\\User\\Manager",
        "type": "->",
        "args": [
          null
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "schedule",
        "class": "OCA\\DAV\\CalDAV\\Schedule\\IMipPlugin",
        "type": "->",
        "args": [
          [
            "Sabre\\VObject\\ITip\\Message",
            "cf33c5ec-…",
            "VEVENT",
            "REQUEST",
            1,
            "mailto:f…",
            null,
            "mailto:s…",
            null,
            "1.2;Message delivered locally",
            [
              "Sabre\\VObject\\Component\\VCalendar",
              null,
              "VCALENDAR"
            ],
            true
          ]
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Schedule/Plugin.php",
        "line": 350,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "schedule",
          [
            [
              "Sabre\\VObject\\ITip\\Message",
              "cf33c5ec-…",
              "VEVENT",
              "REQUEST",
              1,
              "mailto:f…",
              null,
              "mailto:s…",
              null,
              "1.2;Message delivered locally",
              [
                "Sabre\\VObject\\Component\\VCalendar",
                null,
                "VCALENDAR"
              ],
              true
            ]
          ]
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Schedule/Plugin.php",
        "line": 627,
        "function": "deliver",
        "class": "Sabre\\CalDAV\\Schedule\\Plugin",
        "type": "->",
        "args": [
          [
            "Sabre\\VObject\\ITip\\Message",
            "cf33c5ec-…",
            "VEVENT",
            "REQUEST",
            1,
            "mailto:f…",
            null,
            "mailto:s…",
            null,
            "1.2;Message delivered locally",
            [
              "Sabre\\VObject\\Component\\VCalendar",
              null,
              "VCALENDAR"
            ],
            true
          ]
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Schedule/Plugin.php",
        "line": 337,
        "function": "processICalendarChange",
        "class": "Sabre\\CalDAV\\Schedule\\Plugin",
        "type": "->",
        "args": [
          null,
          [
            "Sabre\\VObject\\Component\\VCalendar",
            null,
            "VCALENDAR"
          ],
          [
            "mailto:f…",
            "/remote.php/dav/principals/users/…/"
          ],
          [],
          true
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/apps/dav/lib/CalDAV/Schedule/Plugin.php",
        "line": 165,
        "function": "calendarObjectChange",
        "class": "Sabre\\CalDAV\\Schedule\\Plugin",
        "type": "->",
        "args": [
          [
            "Sabre\\HTTP\\Request"
          ],
          [
            "Sabre\\HTTP\\Response"
          ],
          [
            "Sabre\\VObject\\Component\\VCalendar",
            null,
            "VCALENDAR"
          ],
          "calendars/…/…",
          true,
          true
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "calendarObjectChange",
        "class": "OCA\\DAV\\CalDAV\\Schedule\\Plugin",
        "type": "->",
        "args": [
          [
            "Sabre\\HTTP\\Request"
          ],
          [
            "Sabre\\HTTP\\Response"
          ],
          [
            "Sabre\\VObject\\Component\\VCalendar",
            null,
            "VCALENDAR"
          ],
          "calendars/…/…",
          true,
          true
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Plugin.php",
        "line": 897,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "calendarObjectChange",
          [
            [
              "Sabre\\HTTP\\Request"
            ],
            [
              "Sabre\\HTTP\\Response"
            ],
            [
              "Sabre\\VObject\\Component\\VCalendar",
              null,
              "VCALENDAR"
            ],
            "calendars/…/…",
            true,
            "And 1 more entries, set log level to debug to see all entries"
          ]
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/dav/lib/CalDAV/Plugin.php",
        "line": 766,
        "function": "validateICalendar",
        "class": "Sabre\\CalDAV\\Plugin",
        "type": "->",
        "args": [
          "BEGIN:VCALENDAR\r\n…",
          "calendars/…/…/cf33c5ec-….ics",
          false,
          [
            "Sabre\\HTTP\\Request"
          ],
          [
            "Sabre\\HTTP\\Response"
          ],
          true
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "beforeCreateFile",
        "class": "Sabre\\CalDAV\\Plugin",
        "type": "->",
        "args": [
          "calendars/…/…/cf33c5ec-….ics",
          "BEGIN:VCALENDAR\r\nPRODID…",
          [
            "OCA\\DAV\\CalDAV\\Calendar"
          ],
          false
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 1094,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "beforeCreateFile",
          [
            "calendars/…/…/cf33c5ec-….ics",
            "BEGIN:VCALENDAR\r\nPRODID…",
            [
              "OCA\\DAV\\CalDAV\\Calendar"
            ],
            false
          ]
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php",
        "line": 504,
        "function": "createFile",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "calendars/…/…/cf33c5ec-….ics",
          "BEGIN:VCALENDAR\r\nPRODID…",
          null
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
        "line": 89,
        "function": "httpPut",
        "class": "Sabre\\DAV\\CorePlugin",
        "type": "->",
        "args": [
          [
            "Sabre\\HTTP\\Request"
          ],
          [
            "Sabre\\HTTP\\Response"
          ]
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 472,
        "function": "emit",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          "method:PUT",
          [
            [
              "Sabre\\HTTP\\Request"
            ],
            [
              "Sabre\\HTTP\\Response"
            ]
          ]
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 253,
        "function": "invokeMethod",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": [
          [
            "Sabre\\HTTP\\Request"
          ],
          [
            "Sabre\\HTTP\\Response"
          ]
        ]
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php",
        "line": 321,
        "function": "start",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/apps/dav/lib/Server.php",
        "line": 363,
        "function": "exec",
        "class": "Sabre\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/apps/dav/appinfo/v2/remote.php",
        "line": 35,
        "function": "exec",
        "class": "OCA\\DAV\\Server",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/cloud.nextcloud.com/nextcloud/remote.php",
        "line": 171,
        "args": [
          "/var/www/cloud.nextcloud.com/nextcloud/apps/dav/appinfo/v2/remote.php"
        ],
        "function": "require_once"
      }
    ],
    "File": "/var/www/cloud.nextcloud.com/nextcloud/lib/private/User/Manager.php",
    "Line": 193,
    "message": "OC\\User\\Manager::getDisplayName(): Argument #1 ($uid) must be of type string, null given, called in /var/www/cloud.nextcloud.com/nextcloud/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php on line 213",
    "exception": {},
    "CustomMessage": "OC\\User\\Manager::getDisplayName(): Argument #1 ($uid) must be of type string, null given, called in /var/www/cloud.nextcloud.com/nextcloud/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php on line 213"
  }
}

@st3iny st3iny added this to the Nextcloud 26 milestone Mar 1, 2023
@blizzz blizzz mentioned this pull request Mar 2, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: iMip Email: Invalid type of recipient name parameter
4 participants