From e078f9fdac8f666e2d2aad1b1cc8ba3aadb68ab2 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Thu, 29 Jan 2015 10:47:33 +0100 Subject: Introduce url_remove_credentials() function See https://github.com/FreshRSS/FreshRSS/issues/711 --- lib/lib_rss.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/lib_rss.php b/lib/lib_rss.php index 68abe602c..d4f41cf5c 100644 --- a/lib/lib_rss.php +++ b/lib/lib_rss.php @@ -429,3 +429,13 @@ function array_push_unique(&$array, $value) { function array_remove(&$array, $value) { $array = array_diff($array, array($value)); } + + +/** + * Sanitize a URL by removing HTTP credentials. + * @param $url the URL to sanitize. + * @return the same URL without HTTP credentials. + */ +function url_remove_credentials($url) { + return preg_replace('#((.+)://)((.+)@)?(.+)#', '${1}${5}', $url); +} -- cgit v1.2.3