diff options
author | Eric Covener <covener@apache.org> | 2024-06-25 21:43:15 +0200 |
---|---|---|
committer | Eric Covener <covener@apache.org> | 2024-06-25 21:43:15 +0200 |
commit | f823c19fe4e16ac811b7a3a645ed18f7d8942330 (patch) | |
tree | 4c781110a92fd79e0b122cf12926537797f8ec7e /modules/mappers/mod_rewrite.c | |
parent | validate hostname (diff) | |
download | apache2-f823c19fe4e16ac811b7a3a645ed18f7d8942330.tar.xz apache2-f823c19fe4e16ac811b7a3a645ed18f7d8942330.zip |
fix comparison of local path on Windows
Submitted By: Yann Ylavic
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1918623 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | modules/mappers/mod_rewrite.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index 09a242e286..0d4ecbc9dd 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -683,6 +683,19 @@ static unsigned is_absolute_uri(char *uri, int *supportsqs) return 0; } +static int is_absolute_path(const char *path) +{ +#ifndef WIN32 + return (path[0] == '/'); +#else +#define IS_SLASH(c) ((c) == '/' || (c) == '\\') + /* "//", "\\", "x:/" and "x:\" are absolute paths on Windows */ + return ((IS_SLASH(path[0]) && path[1] == path[0]) + || (apr_isalpha(path[0]) && path[1] == ':' && IS_SLASH(path[2]))); +#undef IS_SLASH +#endif +} + static const char c2x_table[] = "0123456789abcdef"; static APR_INLINE unsigned char *c2x(unsigned what, unsigned char prefix, @@ -4396,7 +4409,9 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p, * (1) it's an absolute URL path and * (2) it's a full qualified URL */ - if (!is_proxyreq && *newuri != '/' && !is_absolute_uri(newuri, NULL)) { + if (!is_proxyreq + && !is_absolute_path(newuri) + && !is_absolute_uri(newuri, NULL)) { if (ctx->perdir) { rewritelog(r, 3, ctx->perdir, "add per-dir prefix: %s -> %s%s", newuri, ctx->perdir, newuri); |