]> granicus.if.org Git - apache/commitdiff
Fix a mismatching issue, where index.html.foo.en had recognized .html and
authorWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 3 Oct 2001 01:18:22 +0000 (01:18 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Wed, 3 Oct 2001 01:18:22 +0000 (01:18 +0000)
  .en components, and exceptions index and foo.  This patch will ignore the
  'missing' exception html from the request, and go on to test the exception
  foo in the list.

  This does -not- imply that a request for index.foo will succeed, in the
  example above.  The pattern match tests index.foo[.*] so we wouldn't find
  index.html.foo.anything.  The pattern matching proposed at one time by
  Francis Daly would allow index.foo to succeed as well [although many to
  many matching is dangerous, see comments in this patch.]

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91249 13f79535-47bb-0310-9956-ffa450edef68

modules/mappers/mod_negotiation.c

index bde4dab442112195cc958d0f7b0aec99d8910d6a..cedb4efee4df9b58159f3497cb716d49c2c0c5c0 100644 (file)
@@ -1100,26 +1100,41 @@ static int read_types_multi(negotiation_state *neg)
             continue;
         }
 
-        /*
-         * Simple enough for now, every unregonized bit better match
-         * our base name.  When we break up our base name and allow
-         * index.en to match index.html.en, this gets tricker.
-         * XXX: index.html.foo won't be caught by testing index.html
-         * since the exceptions result is index.foo - this should be
-         * fixed as part of a new match-parts logic here.
+        /* Each unregonized bit better match our base name, in sequence.
+         * A test of index.html.foo will match index.foo or index.html.foo,
+         * but it will never transpose the segments and allow index.foo.html
+         * because that would introduce too much CPU consumption.  Better that
+         * we don't attempt a many-to-many match here.
          */
         {
-            char *base = apr_array_pstrcat(sub_req->pool, exception_list, '.');
-            int base_len = strlen(base);
-            if (base_len > prefix_len 
+            int nexcept = exception_list->nelts;
+            char **except = (char**)exception_list->elts;
+            char *segstart = filp, *segend, saveend;
+
+            while (*segstart && nexcept) {
+                if (!(segend = strchr(segstart, '.')))
+                    segend = strchr(segstart, '\0');
+                saveend = *segend;
+                *segend = '\0';
+                    
 #ifdef CASE_BLIND_FILESYSTEM
-                || strncasecmp(base, filp, base_len)
+                if (strcasecmp(segstart, *except) == 0) {
 #else
-                || strncmp(base, filp, base_len)
+                if (strcmp(segstart, *except) == 0) {
 #endif
-                || (prefix_len > base_len && filp[base_len] != '.')) {
-                /* 
-                 * Something you don't know is, something you don't know...
+                    --nexcept;
+                    ++except;                    
+                }         
+                
+                if (!saveend)
+                    break;
+
+                *segend = saveend;
+                segstart = segend + 1;
+            }
+
+            if (nexcept) {
+                /* Something you don't know is, something you don't know...
                  */
                 ap_destroy_sub_req(sub_req);
                 continue;