diff options
author | Eric Covener <covener@apache.org> | 2024-06-26 12:09:29 +0200 |
---|---|---|
committer | Eric Covener <covener@apache.org> | 2024-06-26 12:09:29 +0200 |
commit | f2db4112861b10192de7a1a42321b42cb8a2ba55 (patch) | |
tree | b5708fae5ed5a0767684115716290217f24c8e9f /server | |
parent | mod_proxy: follow up to r1918626: Simplify ap_proxy_fixup_uds_filename() and ... (diff) | |
download | apache2-f2db4112861b10192de7a1a42321b42cb8a2ba55.tar.xz apache2-f2db4112861b10192de7a1a42321b42cb8a2ba55.zip |
factor out IS_SLASH, perdir fix
in per-dir, the filename will be internally redirected, so / is OK too.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918651 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server')
-rw-r--r-- | server/util.c | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/server/util.c b/server/util.c index 04f40a235a..bca2636fd2 100644 --- a/server/util.c +++ b/server/util.c @@ -77,17 +77,6 @@ */ #include "test_char.h" -/* Win32/NetWare/OS2 need to check for both forward and back slashes - * in ap_normalize_path() and ap_escape_url(). - */ -#ifdef CASE_BLIND_FILESYSTEM -#define IS_SLASH(s) ((s == '/') || (s == '\\')) -#define SLASHES "/\\" -#else -#define IS_SLASH(s) (s == '/') -#define SLASHES "/" -#endif - /* we know core's module_index is 0 */ #undef APLOG_MODULE_INDEX #define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX @@ -494,7 +483,7 @@ AP_DECLARE(apr_status_t) ap_pregsub_ex(apr_pool_t *p, char **result, /* Forward declare */ static char x2c(const char *what); -#define IS_SLASH_OR_NUL(s) (s == '\0' || IS_SLASH(s)) +#define IS_SLASH_OR_NUL(s) (s == '\0' || AP_IS_SLASH(s)) /* * Inspired by mod_jk's jk_servlet_normalize(). @@ -506,7 +495,7 @@ AP_DECLARE(int) ap_normalize_path(char *path, unsigned int flags) int decode_unreserved = (flags & AP_NORMALIZE_DECODE_UNRESERVED) != 0; int merge_slashes = (flags & AP_NORMALIZE_MERGE_SLASHES) != 0; - if (!IS_SLASH(path[0])) { + if (!AP_IS_SLASH(path[0])) { /* Besides "OPTIONS *", a request-target should start with '/' * per RFC 7230 section 5.3, so anything else is invalid. */ @@ -547,12 +536,12 @@ AP_DECLARE(int) ap_normalize_path(char *path, unsigned int flags) } } - if (w == 0 || IS_SLASH(path[w - 1])) { + if (w == 0 || AP_IS_SLASH(path[w - 1])) { /* Collapse ///// sequences to / */ - if (merge_slashes && IS_SLASH(path[l])) { + if (merge_slashes && AP_IS_SLASH(path[l])) { do { l++; - } while (IS_SLASH(path[l])); + } while (AP_IS_SLASH(path[l])); continue; } @@ -581,7 +570,7 @@ AP_DECLARE(int) ap_normalize_path(char *path, unsigned int flags) if (w > 1) { do { w--; - } while (w && !IS_SLASH(path[w - 1])); + } while (w && !AP_IS_SLASH(path[w - 1])); } else { /* Already at root, ignore and return a failure @@ -1921,7 +1910,7 @@ static int unescape_url(char *url, const char *forbid, const char *reserved, char decoded; decoded = x2c(y + 1); if ((decoded == '\0') - || (forbid_slashes && IS_SLASH(decoded)) + || (forbid_slashes && AP_IS_SLASH(decoded)) || (forbid && ap_strchr_c(forbid, decoded))) { badpath = 1; *x = decoded; @@ -1929,7 +1918,7 @@ static int unescape_url(char *url, const char *forbid, const char *reserved, } else if ((keep_unreserved && TEST_CHAR(decoded, T_URI_UNRESERVED)) - || (keep_slashes && IS_SLASH(decoded)) + || (keep_slashes && AP_IS_SLASH(decoded)) || (reserved && ap_strchr_c(reserved, decoded))) { *x++ = *y++; *x++ = *y++; @@ -1956,7 +1945,7 @@ static int unescape_url(char *url, const char *forbid, const char *reserved, AP_DECLARE(int) ap_unescape_url(char *url) { /* Traditional */ - return unescape_url(url, SLASHES, NULL, 0); + return unescape_url(url, AP_SLASHES, NULL, 0); } AP_DECLARE(int) ap_unescape_url_keep2f(char *url, int decode_slashes) { @@ -1966,7 +1955,7 @@ AP_DECLARE(int) ap_unescape_url_keep2f(char *url, int decode_slashes) return unescape_url(url, NULL, NULL, 0); } else { /* reserve (do not decode) encoded slashes */ - return unescape_url(url, NULL, SLASHES, 0); + return unescape_url(url, NULL, AP_SLASHES, 0); } } AP_DECLARE(int) ap_unescape_url_ex(char *url, unsigned int flags) |