From: Justin Erenkrantz Date: Wed, 29 Jan 2003 17:24:38 +0000 (+0000) Subject: Allow mod_dav to do weak entity comparison function rather than a strong X-Git-Tag: pre_ajp_proxy~2196 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c18a024fe5641c96babac03ad8aa2c1a0edcbbc;p=apache Allow mod_dav to do weak entity comparison function rather than a strong entity comparison function. (i.e. it will optionally strip the W/ prefix.) PR: 14921 (kinda, but not really) git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@98536 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 0bb2afbe0d..b9fa97a27e 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) Allow mod_dav to do weak entity comparison functions. + [Justin Erenkrantz] + *) Fix If header parsing when a non-mod_dav lock token is passed to it. PR 16452. [Justin Erenkrantz] diff --git a/modules/dav/main/util.c b/modules/dav/main/util.c index 8cbc76a970..ea44b10783 100644 --- a/modules/dav/main/util.c +++ b/modules/dav/main/util.c @@ -1072,7 +1072,34 @@ static dav_error * dav_validate_resource_state(apr_pool_t *p, switch(state_list->type) { case dav_if_etag: { - int mismatch = strcmp(state_list->etag, etag); + const char *given_etag, *current_etag; + int mismatch; + + /* Do a weak entity comparison function as defined in + * RFC 2616 13.3.3. + */ + if (state_list->etag[0] == '"' && + state_list->etag[1] == 'W' && + state_list->etag[2] == '/') { + given_etag = apr_pstrdup(p, state_list->etag); + given_etag += 2; + given_etag[0] = '"'; + } + else { + given_etag = state_list->etag; + } + if (etag[0] == '"' && + etag[1] == 'W' && + etag[2] == '/') { + current_etag = apr_pstrdup(p, etag); + current_etag += 2; + current_etag[0] = '"'; + } + else { + current_etag = etag; + } + + mismatch = strcmp(given_etag, current_etag); if (state_list->condition == DAV_IF_COND_NORMAL && mismatch) { /*