From: Andrew Dolgov Date: Mon, 13 Feb 2017 12:25:21 +0000 (+0300) Subject: rewrite_relative_url: cleanup resulting url path while rewriting X-Git-Tag: 17.4~36 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=4a23031fcdb1d0a5e26e6f739088317b10f115c0;p=tt-rss.git rewrite_relative_url: cleanup resulting url path while rewriting --- diff --git a/include/functions2.php b/include/functions2.php index c779d0a8..f3570e56 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); }