diff options
author | Andrew Dolgov <[email protected]> | 2017-02-13 15:25:21 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-02-13 15:25:21 +0300 |
commit | 4a23031fcdb1d0a5e26e6f739088317b10f115c0 (patch) | |
tree | 5d5457fc6212eaad20622ba01c31affdad188c5e | |
parent | ab39e213b3038f2305c415ad4457c680acc5b052 (diff) |
rewrite_relative_url: cleanup resulting url path while rewriting
-rw-r--r-- | include/functions2.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/functions2.php b/include/functions2.php index c779d0a8c..f3570e56b 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -2074,6 +2074,13 @@ return $parts['scheme'] . "://" . $parts['host'] . $parts['path']; } + function cleanup_url_path($path) { + $path = str_replace("/./", "/", $path); + $path = str_replace("//", "/", $path); + + return $path; + } + /** * Converts a (possibly) relative URL to a absolute one. * @@ -2094,6 +2101,7 @@ } else if (strpos($rel_url, "/") === 0) { $parts = parse_url($url); $parts['path'] = $rel_url; + $parts['path'] = cleanup_url_path($parts['path']); return build_url($parts); @@ -2108,6 +2116,7 @@ $dir !== '/' && $dir .= '/'; } $parts['path'] = $dir . $rel_url; + $parts['path'] = cleanup_url_path($parts['path']); return build_url($parts); } |