Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/DAV/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -1581,7 +1581,7 @@ public function getIfConditions(RequestInterface $request)

$matches = [];

$regex = '/(?:\<(?P<uri>.*?)\>\s)?\((?P<not>Not\s)?(?:\<(?P<token>[^\>]*)\>)?(?:\s?)(?:\[(?P<etag>[^\]]*)\])?\)/im';
$regex = '/(?:\<(?P<uri>.*?)\>\s)?\((?P<not>not\b[\x20\t]*)?(?:\<(?P<token>[^\>]*)\>)?(?:\s?)(?:\[(?P<etag>[^\]]*)\])?\)/im';
preg_match_all($regex, $header, $matches, PREG_SET_ORDER);

$conditions = [];
Expand Down
138 changes: 138 additions & 0 deletions tests/Sabre/DAV/GetIfConditionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,75 @@ public function testNotLockToken()
self::assertEquals($compare, $conditions);
}

public function testNotLockTokenWithoutSpace()
{
$request = new HTTP\Request('GET', '/bla', [
'If' => '(Not<opaquelocktoken:token1>)',
]);

$conditions = $this->server->getIfConditions($request);

$compare = [
[
'uri' => 'bla',
'tokens' => [
[
'negate' => true,
'token' => 'opaquelocktoken:token1',
'etag' => '',
],
],
],
];
self::assertEquals($compare, $conditions);
}

public function testUppercaseNotLockTokenWithTab()
{
$request = new HTTP\Request('GET', '/bla', [
'If' => "(NOT\t<opaquelocktoken:token1>)",
]);

$conditions = $this->server->getIfConditions($request);

$compare = [
[
'uri' => 'bla',
'tokens' => [
[
'negate' => true,
'token' => 'opaquelocktoken:token1',
'etag' => '',
],
],
],
];
self::assertEquals($compare, $conditions);
}

public function testUppercaseNotLockTokenWithoutSpace()
{
$request = new HTTP\Request('GET', '/bla', [
'If' => '(NOT<opaquelocktoken:token1>)',
]);

$conditions = $this->server->getIfConditions($request);

$compare = [
[
'uri' => 'bla',
'tokens' => [
[
'negate' => true,
'token' => 'opaquelocktoken:token1',
'etag' => '',
],
],
],
];
self::assertEquals($compare, $conditions);
}

public function testLockTokenUrl()
{
$request = new HTTP\Request('GET', '/bla', [
Expand Down Expand Up @@ -204,6 +273,75 @@ public function testEtag()
self::assertEquals($compare, $conditions);
}

public function testNotEtagWithoutSpace()
{
$request = new HTTP\Request('GET', '/foo', [
'If' => '(Not["etag1"])',
]);

$conditions = $this->server->getIfConditions($request);

$compare = [
[
'uri' => 'foo',
'tokens' => [
[
'negate' => true,
'token' => '',
'etag' => '"etag1"',
],
],
],
];
self::assertEquals($compare, $conditions);
}

public function testUppercaseNotEtagWithTab()
{
$request = new HTTP\Request('GET', '/foo', [
'If' => "(NOT\t[\"etag1\"])",
]);

$conditions = $this->server->getIfConditions($request);

$compare = [
[
'uri' => 'foo',
'tokens' => [
[
'negate' => true,
'token' => '',
'etag' => '"etag1"',
],
],
],
];
self::assertEquals($compare, $conditions);
}

public function testUppercaseNotEtagWithoutSpace()
{
$request = new HTTP\Request('GET', '/foo', [
'If' => '(NOT["etag1"])',
]);

$conditions = $this->server->getIfConditions($request);

$compare = [
[
'uri' => 'foo',
'tokens' => [
[
'negate' => true,
'token' => '',
'etag' => '"etag1"',
],
],
],
];
self::assertEquals($compare, $conditions);
}

public function test2Etags()
{
$request = new HTTP\Request('GET', '/foo', [
Expand Down