httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grega...@apache.org
Subject svn commit: r1202236 - /httpd/httpd/trunk/server/core.c
Date Tue, 15 Nov 2011 15:20:38 GMT
Author: gregames
Date: Tue Nov 15 15:20:38 2011
New Revision: 1202236

URL: http://svn.apache.org/viewvc?rev=1202236&view=rev
Log:
ap_core_translate: factor out duplicate code.  no functional change.

Modified:
    httpd/httpd/trunk/server/core.c

Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1202236&r1=1202235&r2=1202236&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Tue Nov 15 15:20:38 2011
@@ -4062,6 +4062,7 @@ AP_INIT_TAKE1("TraceEnable", set_trace_e
 AP_DECLARE_NONSTD(int) ap_core_translate(request_rec *r)
 {
     apr_status_t rv;
+    char *path;
 
     /* XXX this seems too specific, this should probably become
      * some general-case test
@@ -4081,46 +4082,31 @@ AP_DECLARE_NONSTD(int) ap_core_translate
             || r->uri[r->server->pathlen] == '/'
             || r->uri[r->server->pathlen] == '\0'))
     {
-        /* skip all leading /'s (e.g. http://localhost///foo)
-         * so we are looking at only the relative path.
-         */
-        char *path = r->uri + r->server->pathlen;
-        while (*path == '/') {
-            ++path;
-        }
-        if ((rv = apr_filepath_merge(&r->filename, ap_document_root(r), path,
-                                     APR_FILEPATH_TRUENAME
-                                   | APR_FILEPATH_SECUREROOT, r->pool))
-                    != APR_SUCCESS) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
-                         "Cannot map %s to file", r->the_request);
-            return HTTP_FORBIDDEN;
-        }
-        r->canonical_filename = r->filename;
+        path = r->uri + r->server->pathlen;
     }
     else {
-        /*
-         * Make sure that we do not mess up the translation by adding two
-         * /'s in a row.  This happens under windows when the document
-         * root ends with a /
-         */
-        /* skip all leading /'s (e.g. http://localhost///foo)
-         * so we are looking at only the relative path.
-         */
-        char *path = r->uri;
-        while (*path == '/') {
-            ++path;
-        }
-        if ((rv = apr_filepath_merge(&r->filename, ap_document_root(r), path,
-                                     APR_FILEPATH_TRUENAME
-                                   | APR_FILEPATH_SECUREROOT, r->pool))
-                    != APR_SUCCESS) {
-            ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
-                         "Cannot map %s to file", r->the_request);
-            return HTTP_FORBIDDEN;
-        }
-        r->canonical_filename = r->filename;
+        path = r->uri;
+    }
+    /*
+     * Make sure that we do not mess up the translation by adding two
+     * /'s in a row.  This happens under windows when the document
+     * root ends with a /
+     */
+    /* skip all leading /'s (e.g. http://localhost///foo)
+     * so we are looking at only the relative path.
+     */
+    while (*path == '/') {
+        ++path;
+    }
+    if ((rv = apr_filepath_merge(&r->filename, ap_document_root(r), path,
+                                 APR_FILEPATH_TRUENAME
+                               | APR_FILEPATH_SECUREROOT, r->pool))
+                != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
+                     "Cannot map %s to file", r->the_request);
+        return HTTP_FORBIDDEN;
     }
+    r->canonical_filename = r->filename;
 
     return OK;
 }



Mime
View raw message