Skip to content

A free, self-hostable news aggregator…

Introduce url_remove_credentials() function

Marien Fressinaude078f9fdac8f
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);
+}