aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/path_helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/path_helper.php')
-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);
+ }
}