You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by wr...@apache.org on 2001/10/03 03:18:22 UTC

cvs commit: httpd-2.0/modules/mappers mod_negotiation.c

wrowe       01/10/02 18:18:22

  Modified:    modules/mappers mod_negotiation.c
  Log:
    Fix a mismatching issue, where index.html.foo.en had recognized .html and
    .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.]
  
  Revision  Changes    Path
  1.83      +30 -15    httpd-2.0/modules/mappers/mod_negotiation.c
  
  Index: mod_negotiation.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_negotiation.c,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- mod_negotiation.c	2001/09/19 05:52:42	1.82
  +++ mod_negotiation.c	2001/10/03 01:18:22	1.83
  @@ -1100,26 +1100,41 @@
               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;