From ee1ddf4ee925080adce23ee43d9a68fae207f4d5 Mon Sep 17 00:00:00 2001 From: Bradley Nicholes Date: Tue, 21 Aug 2001 20:22:09 +0000 Subject: [PATCH] Fixed ap_os_canonical_filename() and ap_os_is_path_absolute() so that they would recognize special file names such as proxy:http://blah correctly. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@90475 13f79535-47bb-0310-9956-ffa450edef68 --- src/os/netware/os.c | 30 ++++++++++++++++++------------ src/os/netware/os.h | 25 ++++++++++++++++--------- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/src/os/netware/os.c b/src/os/netware/os.c index 5b534090df9..4aeaeead602 100644 --- a/src/os/netware/os.c +++ b/src/os/netware/os.c @@ -168,19 +168,25 @@ char *ap_os_canonical_filename(pool *pPool, const char *szFile) char *slash_test; bslash2slash(pNewName); - if ((pNewName[0] == '/') && (strchr (pNewName, ':') == NULL)) - { - char vol[256]; - - _splitpath (ap_server_root, vol, NULL, NULL, NULL); - pNewName = ap_pstrcat (pPool, vol, pNewName, NULL); - } - if ((slash_test = strchr(pNewName, ':')) && (*(slash_test+1) != '/')) - { - char vol[_MAX_VOLUME+1]; + /* Don't try to canonicalize a filename that isn't even valid + This way we don't mess up proxy requests or other kinds + of special filenames. + */ + if (ap_os_is_filename_valid(pNewName)) { + if ((pNewName[0] == '/') && (strchr (pNewName, ':') == NULL)) + { + char vol[256]; + + _splitpath (ap_server_root, vol, NULL, NULL, NULL); + pNewName = ap_pstrcat (pPool, vol, pNewName, NULL); + } + if ((slash_test = strchr(pNewName, ':')) && (*(slash_test+1) != '/')) + { + char vol[_MAX_VOLUME+1]; - _splitpath (pNewName, vol, NULL, NULL, NULL); - pNewName = ap_pstrcat (pPool, vol, "/", pNewName+strlen(vol), NULL); + _splitpath (pNewName, vol, NULL, NULL, NULL); + pNewName = ap_pstrcat (pPool, vol, "/", pNewName+strlen(vol), NULL); + } } strlwr(pNewName); return pNewName; diff --git a/src/os/netware/os.h b/src/os/netware/os.h index 85e363e6e48..edb92449b89 100644 --- a/src/os/netware/os.h +++ b/src/os/netware/os.h @@ -138,16 +138,23 @@ void clean_parent_exit(int code); inline int ap_os_is_path_absolute(const char *file) { - char *s = strchr (file, ':'); + char *s = strstr (file, "://"); + + /* First make sure we aren't looking at a URL such as + a proxy:http://blah. + */ + if (!s) { + s = strchr (file, ':'); - if (s) { - if (strncmp(s, "://", 3) != 0) - /* XXX: we assume that everything before the : is letters */ - return 1; - } - else { - if (file[0] == '/') - return 1; + if (s) { + if (strncmp(s, "://", 3) != 0) + /* XXX: we assume that everything before the : is letters */ + return 1; + } + else { + if (file[0] == '/') + return 1; + } } return 0; -- 2.47.2