Introduce url_remove_credentials() function

See https://github.com/FreshRSS/FreshRSS/issues/711
This commit is contained in:
Marien Fressinaud
2015-01-29 10:47:33 +01:00
parent 40f45c92ed
commit e078f9fdac

View File

@@ -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);
}