httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n.@apache.org
Subject cvs commit: httpd-2.0/modules/mappers mod_rewrite.c
Date Fri, 18 Jul 2003 00:38:45 GMT
nd          2003/07/17 17:38:44

  Modified:    modules/mappers mod_rewrite.c
  Log:
  when prefixing document root, use the core translator instead
  of baking our own. The core function is much better maintained
  and probably more safe.
  Additionally this removes just another fixed buffer :)
  
  Revision  Changes    Path
  1.167     +20 -28    httpd-2.0/modules/mappers/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.c,v
  retrieving revision 1.166
  retrieving revision 1.167
  diff -u -r1.166 -r1.167
  --- mod_rewrite.c	17 Jul 2003 21:22:50 -0000	1.166
  +++ mod_rewrite.c	18 Jul 2003 00:38:44 -0000	1.167
  @@ -1149,12 +1149,8 @@
       char *thisport;
       const char *thisurl;
       char buf[512];
  -    char docroot[512];
  -    const char *ccp;
       unsigned int port;
       int rulestatus;
  -    int n;
  -    int l;
   
       /*
        *  retrieve the config structures
  @@ -1289,6 +1285,8 @@
               return OK;
           }
           else if ((skip = is_absolute_uri(r->filename)) > 0) {
  +            int n;
  +
               /* it was finally rewritten to a remote URL */
   
               if (rulestatus != ACTION_NOESCAPE) {
  @@ -1359,8 +1357,8 @@
                   return HTTP_BAD_REQUEST;
               }
   
  -            /* if there is no valid prefix, we have
  -             * to emulate the translator from the core and
  +            /* if there is no valid prefix, we call
  +             * the translator from the core and
                * prefix the filename with document_root
                *
                * NOTICE:
  @@ -1379,29 +1377,23 @@
                * because we only do stat() on the first directory
                * and this gets cached by the kernel for along time!
                */
  -            n = prefix_stat(r->filename, r->pool);
  -            if (n == 0) {
  -                if ((ccp = ap_document_root(r)) != NULL) {
  -                    l = apr_cpystrn(docroot, ccp, sizeof(docroot)) - docroot;
  -
  -                    /* always NOT have a trailing slash */
  -                    if (docroot[l-1] == '/') {
  -                        docroot[l-1] = '\0';
  -                    }
  -                    if (r->server->path
  -                        && !strncmp(r->filename, r->server->path,
  -                                    r->server->pathlen)) {
  -                        r->filename = apr_pstrcat(r->pool, docroot,
  -                                                  (r->filename +
  -                                                   r->server->pathlen), NULL);
  -                    }
  -                    else {
  -                        r->filename = apr_pstrcat(r->pool, docroot,
  -                                                  r->filename, NULL);
  -                    }
  -                    rewritelog(r, 2, "prefixed with document_root to %s",
  -                               r->filename);
  +            if (!prefix_stat(r->filename, r->pool)) {
  +                int res;
  +                char *tmp = r->uri;
  +
  +                r->uri = r->filename;
  +                res = ap_core_translate(r);
  +                r->uri = tmp;
  +
  +                if (res != OK) {
  +                    rewritelog(r, 1, "prefixing with document_root of %s "
  +                                     "FAILED", r->filename);
  +
  +                    return res;
                   }
  +
  +                rewritelog(r, 2, "prefixed with document_root to %s",
  +                           r->filename);
               }
   
               rewritelog(r, 1, "go-ahead with %s [OK]", r->filename);
  
  
  

Mime
View raw message