aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-12-21 20:08:00 +0100
committerMarc Alexander <admin@m-a-styles.de>2013-12-21 20:08:00 +0100
commitd9358c26da6737044a3c10893e7b954176b205d2 (patch)
tree69be68f104f4e7bf2627debce6faa83b95ab60c3 /phpBB/phpbb
parent235d2069e0e7cecfd51d4eed5c875cc865f35486 (diff)
downloadforums-d9358c26da6737044a3c10893e7b954176b205d2.tar
forums-d9358c26da6737044a3c10893e7b954176b205d2.tar.gz
forums-d9358c26da6737044a3c10893e7b954176b205d2.tar.bz2
forums-d9358c26da6737044a3c10893e7b954176b205d2.tar.xz
forums-d9358c26da6737044a3c10893e7b954176b205d2.zip
[ticket/11997] Add clean_url() method to path_helper
This method will get rid of unnecessary . and .. in URLs. PHPBB3-11997
Diffstat (limited to 'phpBB/phpbb')
-rw-r--r--phpBB/phpbb/path_helper.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/phpBB/phpbb/path_helper.php b/phpBB/phpbb/path_helper.php
index f6587fa101..cd4c20bb7d 100644
--- a/phpBB/phpbb/path_helper.php
+++ b/phpBB/phpbb/path_helper.php
@@ -207,4 +207,27 @@ class path_helper
return generate_board_url() . $url;
}
+
+ /**
+ * Eliminates useless . and .. components from specified URL
+ *
+ * @param string $url URL to clean
+ *
+ * @return string Cleaned URL
+ */
+ public function clean_url($url)
+ {
+ $delimiter_position = strpos($url, '://');
+ // URL should contain :// but it shouldn't start with it.
+ // Do not clean URLs that do not fit these constraints.
+ if (empty($delimiter_position))
+ {
+ return $url;
+ }
+ $scheme = substr($url, 0, $delimiter_position) . '://';
+ // Add length of URL delimiter to position
+ $path = substr($url, $delimiter_position + 3);
+
+ return $scheme . $this->filesystem->clean_path($path);
+ }
}