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 mod_rewrite.h
Date Mon, 24 Feb 2003 21:44:15 GMT
nd          2003/02/24 13:44:15

  Modified:    modules/mappers mod_rewrite.c mod_rewrite.h
  Log:
  This is part two.
  It fixes the prefix_stat function. (which does a stat call on the first
  path segment). This function was still tailored for unix systems only.
  It should work on other systems as well now.
  
  Revision  Changes    Path
  1.143     +33 -13    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.142
  retrieving revision 1.143
  diff -u -r1.142 -r1.143
  --- mod_rewrite.c	24 Feb 2003 21:34:51 -0000	1.142
  +++ mod_rewrite.c	24 Feb 2003 21:44:15 -0000	1.143
  @@ -1083,7 +1083,6 @@
       char docroot[512];
       char *cp, *cp2;
       const char *ccp;
  -    apr_finfo_t finfo;
       unsigned int port;
       int rulestatus;
       int n;
  @@ -1313,7 +1312,7 @@
                * because we only do stat() on the first directory
                * and this gets cached by the kernel for along time!
                */
  -            n = prefix_stat(r->filename, &finfo);
  +            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;
  @@ -4219,24 +4218,45 @@
   **
   */
   
  -static int prefix_stat(const char *path, apr_finfo_t *sb)
  +static int prefix_stat(const char *path, apr_pool_t *pool)
   {
  -    char curpath[LONG_STRING_LEN];
  -    char *cp;
  +    const char *curpath = path;
  +    char *root;
  +    char *slash;
  +    char *statpath;
  +    apr_status_t rv;
   
  -    apr_cpystrn(curpath, path, sizeof(curpath));
  -    if (curpath[0] != '/') {
  +    rv = apr_filepath_root(&root, &curpath, APR_FILEPATH_TRUENAME, pool);
  +
  +    if (rv != APR_SUCCESS) {
           return 0;
       }
  -    if ((cp = strchr(curpath+1, '/')) != NULL) {
  -        *cp = '\0';
  -    }
  -    if (apr_stat(sb, curpath, APR_FINFO_MIN, NULL) == APR_SUCCESS) {
  -        return 1;
  +
  +    /* let's recognize slashes only, the mod_rewrite semantics are opaque
  +     * enough.
  +     */
  +    if ((slash = ap_strchr(curpath, '/')) != NULL) {
  +        rv = apr_filepath_merge(&statpath, root,
  +                                apr_pstrndup(pool, curpath,
  +                                             (apr_size_t)(slash - curpath)),
  +                                APR_FILEPATH_NOTABOVEROOT |
  +                                APR_FILEPATH_NOTRELATIVE, pool);
       }
       else {
  -        return 0;
  +        rv = apr_filepath_merge(&statpath, root, curpath,
  +                                APR_FILEPATH_NOTABOVEROOT |
  +                                APR_FILEPATH_NOTRELATIVE, pool);
       }
  +
  +    if (rv == APR_SUCCESS) {
  +        apr_finfo_t sb;
  +        
  +        if (apr_stat(&sb, statpath, APR_FINFO_MIN, pool) == APR_SUCCESS) {
  +            return 1;
  +        }
  +    }
  +
  +    return 0;
   }
   
   
  
  
  
  1.41      +1 -1      httpd-2.0/modules/mappers/mod_rewrite.h
  
  Index: mod_rewrite.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/mappers/mod_rewrite.h,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- mod_rewrite.h	3 Feb 2003 17:53:06 -0000	1.40
  +++ mod_rewrite.h	24 Feb 2003 21:44:15 -0000	1.41
  @@ -462,7 +462,7 @@
   static char  *subst_prefix_path(request_rec *r, char *input, char *match,
                                   const char *subst);
   static int    parseargline(char *str, char **a1, char **a2, char **a3);
  -static int    prefix_stat(const char *path, apr_finfo_t *sb);
  +static int    prefix_stat(const char *path, apr_pool_t *pool);
   static void   add_env_variable(request_rec *r, char *s);
   static void   add_cookie(request_rec *r, char *s);
   static int    subreq_ok(request_rec *r);
  
  
  

Mime
View raw message