Skip to content

Commit

Permalink
fix(carddav): limit vcard size
Browse files Browse the repository at this point in the history
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
  • Loading branch information
SebastianKrupinski committed Jul 4, 2024
1 parent 794b44e commit c740a5b
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions apps/dav/lib/CardDAV/Validation/CardDavValidatePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

use OCA\DAV\AppInfo\Application;
use OCP\IAppConfig;
use OCP\IUserSession;
use Sabre\DAV\Server;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\ServerPlugin;
Expand All @@ -20,20 +19,14 @@
class CardDavValidatePlugin extends ServerPlugin {

public function __construct(
private IAppConfig $config,
private IUserSession $userSession
private IAppConfig $config
) {}

public function initialize(Server $server): void {
$server->on('beforeMethod:PUT', [$this, 'beforePut']);
}

public function beforePut(RequestInterface $request, ResponseInterface $response): bool {
// evaluate if user is logged in
if ($this->userSession->getUser() === null) {
// We only care about authenticated users here
return false;
}
// evaluate if card size exceeds defined limit
$cardSizeLimit = $this->config->getValueInt(Application::APP_ID, 'card_size_limit', 5242880);
if ((int) $request->getRawServerValue('CONTENT_LENGTH') > $cardSizeLimit) {
Expand Down

0 comments on commit c740a5b

Please sign in to comment.