Skip to content

Evaluate WebDAV If conditions against all the lock tokens of a resource - #1259

Open
arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:webdav-if-not
Open

arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:webdav-if-not

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

Each condition of an If header list is evaluated once per lock token of the resource. A resource without locks has no tokens, so every condition, including Not conditions, evaluates to false and the request fails with 412. With several lock tokens, Not <token> is true as soon as one of the other tokens differs, even though the resource is locked with that token.

RFC 4918, section 10.4.3: prefixing a condition with "Not" reverses the result of the evaluation, and if the header evaluates to true "execution of the request can proceed as if the header wasn't present". Section 10.4.8 gives (Not <DAV:no-lock>) as a condition that always evaluates to true.

A state token condition now matches if the token is one of the lock tokens of the resource, and a list is evaluated once against all the tokens.

Tested on a local Tomcat with PUT on an existing file:

If before after
(Not <urn:x>), file not locked 412 204
(Not <DAV:no-lock>), file not locked 412 204
(<urn:x>), file not locked 412 412
(Not <token>), file locked with token 412 412
(<token>), file locked with token 204 204

httpd mod_dav returns 204 for the first two. The new tests in TestWebdavIfHeader fail without the change.

Each condition of an If header list was evaluated once per lock token of
the resource. A resource without locks has no tokens, so every condition,
including "Not" conditions and entity tags, evaluated to false and the
request failed with 412. With several lock tokens, "Not <token>" was true
as soon as one of the other tokens differed.

RFC 4918, section 10.4.3: "Not" reverses the result of the evaluation of
a condition, and section 10.4.8 gives "(Not <DAV:no-lock>)" as a condition
that always evaluates to true. A state token condition now matches if the
token is one of the lock tokens of the resource.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant