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 Thu, 27 Mar 2003 22:40:55 GMT
nd          2003/03/27 14:40:55

  Modified:    modules/mappers Tag: APACHE_2_0_BRANCH mod_rewrite.c
                        mod_rewrite.h
  Log:
  Fix 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.
  
  Obtained from: 2.1 (r1.143)
  Reviewed by: Brad Nicholes, Will Rowe
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.135.2.9 +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.135.2.8
  retrieving revision 1.135.2.9
  diff -u -r1.135.2.8 -r1.135.2.9
  --- mod_rewrite.c	27 Mar 2003 22:37:48 -0000	1.135.2.8
  +++ mod_rewrite.c	27 Mar 2003 22:40:55 -0000	1.135.2.9
  @@ -1105,7 +1105,6 @@
       char docroot[512];
       char *cp, *cp2;
       const char *ccp;
  -    apr_finfo_t finfo;
       unsigned int port;
       int rulestatus;
       int n;
  @@ -1335,7 +1334,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;
  @@ -4303,24 +4302,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;
  +    const char *root;
  +    const 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_c(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.39.2.3  +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.39.2.2
  retrieving revision 1.39.2.3
  diff -u -r1.39.2.2 -r1.39.2.3
  --- mod_rewrite.h	19 Mar 2003 12:50:57 -0000	1.39.2.2
  +++ mod_rewrite.h	27 Mar 2003 22:40:55 -0000	1.39.2.3
  @@ -472,7 +472,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