]> git.wh0rd.org Git - tt-rss.git/commitdiff
rewrite_relative_url: cleanup resulting url path while rewriting
authorAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Mon, 13 Feb 2017 12:25:21 +0000 (15:25 +0300)
committerAndrew Dolgov <noreply@madoka.volgo-balt.ru>
Mon, 13 Feb 2017 12:25:21 +0000 (15:25 +0300)
include/functions2.php

index c779d0a8cbabc7b7f6104f0e892bc7cb5ca8e7f8..f3570e56bb1d463621cc2ea6d0e104a8d6bd8fae 100644 (file)
                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.
         *
                } 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);
 
                                $dir !== '/' && $dir .= '/';
                        }
                        $parts['path'] = $dir . $rel_url;
+                       $parts['path'] = cleanup_url_path($parts['path']);
 
                        return build_url($parts);
                }