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 <[email protected]>
  • Loading branch information
SebastianKrupinski committed Jul 4, 2024
1 parent bc4e9e9 commit 600202f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/dav/lib/CardDAV/Validation/CardDavValidatePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function initialize(Server $server): void {

public function beforePut(RequestInterface $request, ResponseInterface $response): bool {
// evaluate if card size exceeds defined limit
$cardSizeLimit = $this->config->getValueInt(Application::APP_ID, 'card_size_limit', 5242880);
$cardSizeLimit = (int) $this->config->getValue(Application::APP_ID, 'card_size_limit', '5242880');

Check failure

Code scanning / Psalm

UndefinedInterfaceMethod Error

Method OCP\IAppConfig::getValue does not exist

Check failure on line 32 in apps/dav/lib/CardDAV/Validation/CardDavValidatePlugin.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedInterfaceMethod

apps/dav/lib/CardDAV/Validation/CardDavValidatePlugin.php:32:41: UndefinedInterfaceMethod: Method OCP\IAppConfig::getValue does not exist (see https://psalm.dev/181)
if ((int) $request->getRawServerValue('CONTENT_LENGTH') > $cardSizeLimit) {
throw new Forbidden("VCard object exceeds $cardSizeLimit bytes");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public function testPutSizeLessThenLimit(): void {

// construct method responses
$this->config
->method('getValueInt')
->with('dav', 'card_size_limit', 5242880)
->willReturn(5242880);
->method('getValue')
->with('dav', 'card_size_limit', '5242880')
->willReturn('5242880');
$this->request
->method('getRawServerValue')
->with('CONTENT_LENGTH')
Expand All @@ -57,9 +57,9 @@ public function testPutSizeMoreThenLimit(): void {

// construct method responses
$this->config
->method('getValueInt')
->with('dav', 'card_size_limit', 5242880)
->willReturn(5242880);
->method('getValue')
->with('dav', 'card_size_limit', '5242880')
->willReturn('5242880');
$this->request
->method('getRawServerValue')
->with('CONTENT_LENGTH')
Expand Down

0 comments on commit 600202f

Please sign in to comment.