-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(CorePlugin): Handle
Depth
header in HTTP MOVE
Only `Depth: infinity` is allowed, ref: rfc4918#section-9.9.2 Signed-off-by: Ferdinand Thiessen <[email protected]>
- Loading branch information
Showing
4 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sabre\DAV; | ||
|
||
use Sabre\DAV\Exception\BadRequest; | ||
use Sabre\HTTP; | ||
|
||
class ServerCopyMoveTest extends AbstractServer | ||
{ | ||
/** | ||
* Only 'infinity' and positiv (incl. 0) numbers are allowed | ||
* @dataProvider dataInvalidDepthHeader | ||
*/ | ||
public function testInvalidDepthHeader(?string $headerValue) | ||
{ | ||
$request = new HTTP\Request('COPY', '/', $headerValue !== null ? ['Depth' => $headerValue] : []); | ||
|
||
$this->expectException(BadRequest::class); | ||
$this->server->getCopyAndMoveInfo($request); | ||
} | ||
|
||
public function dataInvalidDepthHeader() { | ||
return [ | ||
['-1'], | ||
['0.5'], | ||
['2f'], | ||
['inf'], | ||
]; | ||
} | ||
|
||
/** | ||
* Only 'infinity' and positiv (incl. 0) numbers are allowed | ||
* @dataProvider dataDepthHeader | ||
*/ | ||
public function testValidDepthHeader(array $depthHeader, string|int $expectedDepth) | ||
{ | ||
$request = new HTTP\Request('COPY', '/', array_merge(['Destination' => '/dst'], $depthHeader)); | ||
|
||
$this->assertEquals($expectedDepth, $this->server->getCopyAndMoveInfo($request)['depth']); | ||
} | ||
|
||
public function dataDepthHeader() { | ||
return [ | ||
[ | ||
[], | ||
'infinity', | ||
], | ||
[ | ||
['Depth' => 'infinity'], | ||
'infinity', | ||
], | ||
[ | ||
['Depth' => 'INFINITY'], | ||
'infinity', | ||
], | ||
[ | ||
['Depth' => '0'], | ||
0, | ||
], | ||
[ | ||
['Depth' => '10'], | ||
10, | ||
], | ||
]; | ||
} | ||
} |