]> granicus.if.org Git - apache/commitdiff
Allow mod_dav to do weak entity comparison function rather than a strong
authorJustin Erenkrantz <jerenkrantz@apache.org>
Wed, 29 Jan 2003 17:24:38 +0000 (17:24 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Wed, 29 Jan 2003 17:24:38 +0000 (17:24 +0000)
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

CHANGES
modules/dav/main/util.c

diff --git a/CHANGES b/CHANGES
index 0bb2afbe0d3a09c7ad6fd252d2671bb89c38d3e4..b9fa97a27e9bdcc3ae8bcc4fc1d529edfbdabc5c 100644 (file)
--- 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]
 
index 8cbc76a9700724ec87019820a528ce1c011e061d..ea44b10783484b75e122b35d85559b5f2a451b3d 100644 (file)
@@ -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) {
                     /*