summaryrefslogtreecommitdiffstats
path: root/modules/mappers/mod_rewrite.c
diff options
context:
space:
mode:
authorEric Covener <covener@apache.org>2024-07-15 14:05:57 +0200
committerEric Covener <covener@apache.org>2024-07-15 14:05:57 +0200
commitb1560d34a37681ebc18baa78588579ed87f9da70 (patch)
tree9c2871091cf8aca076edc90632deb3997ca9ef7d /modules/mappers/mod_rewrite.c
parentcore: ap_location_walk() does not deal with the filesystem (diff)
downloadapache2-b1560d34a37681ebc18baa78588579ed87f9da70.tar.xz
apache2-b1560d34a37681ebc18baa78588579ed87f9da70.zip
merge leading slashes by default
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1919246 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--modules/mappers/mod_rewrite.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c
index 0d928e4b99..439af886ba 100644
--- a/modules/mappers/mod_rewrite.c
+++ b/modules/mappers/mod_rewrite.c
@@ -179,6 +179,7 @@ static const char* really_last_key = "rewrite_really_last";
#define RULEFLAG_ESCAPECTLS (1<<21)
#define RULEFLAG_UNSAFE_PREFIX_STAT (1<<22)
#define RULEFLAG_UNSAFE_ALLOW3F (1<<23)
+#define RULEFLAG_UNC (1<<24)
/* return code of the rewrite rule
* the result may be escaped - or not
@@ -3884,6 +3885,9 @@ static const char *cmd_rewriterule_setflag(apr_pool_t *p, void *_cfg,
else if(!strcasecmp(key, "nsafeAllow3F")) {
cfg->flags |= RULEFLAG_UNSAFE_ALLOW3F;
}
+ else if(!strcasecmp(key, "NC")) {
+ cfg->flags |= RULEFLAG_UNC;
+ }
else {
++error;
}
@@ -4508,6 +4512,16 @@ static rule_return_type apply_rewrite_rule(rewriterule_entry *p,
return RULE_RC_MATCH;
}
+ if (!(p->flags & RULEFLAG_UNC)) {
+ /* merge leading slashes, unless they were literals in the sub */
+ if (!AP_IS_SLASH(p->output[0]) || !AP_IS_SLASH(p->output[1])) {
+ while (AP_IS_SLASH(r->filename[0]) &&
+ AP_IS_SLASH(r->filename[1])) {
+ r->filename++;
+ }
+ }
+ }
+
/* Finally remember the forced mime-type */
force_type_handler(p, ctx);