mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-05-24 08:14:56 -04:00
SimplePie sanitize URLs for syslog
https://github.com/FreshRSS/FreshRSS/issues/711 https://github.com/FreshRSS/FreshRSS/pull/715
This commit is contained in:
@@ -240,7 +240,7 @@ class FreshRSS_Feed extends Minz_Model {
|
||||
$subscribe_url = $feed->subscribe_url(true);
|
||||
}
|
||||
|
||||
$clean_url = url_remove_credentials($subscribe_url);
|
||||
$clean_url = SimplePie_Misc::url_remove_credentials($subscribe_url);
|
||||
if ($subscribe_url !== null && $subscribe_url !== $url) {
|
||||
$this->_url($clean_url);
|
||||
}
|
||||
|
||||
@@ -1554,14 +1554,14 @@ class SimplePie
|
||||
if ($this->data['md5'] === $md5) {
|
||||
if ($this->syslog_enabled)
|
||||
{
|
||||
syslog(LOG_DEBUG, 'SimplePie MD5 cache match for ' . $this->feed_url);
|
||||
syslog(LOG_DEBUG, 'SimplePie MD5 cache match for ' . SimplePie_Misc::url_remove_credentials($this->feed_url));
|
||||
}
|
||||
$cache->touch();
|
||||
return true; //Content unchanged even though server did not send a 304
|
||||
} else {
|
||||
if ($this->syslog_enabled)
|
||||
{
|
||||
syslog(LOG_DEBUG, 'SimplePie MD5 cache no match for ' . $this->feed_url);
|
||||
syslog(LOG_DEBUG, 'SimplePie MD5 cache no match for ' . SimplePie_Misc::url_remove_credentials($this->feed_url));
|
||||
}
|
||||
$this->data['md5'] = $md5;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class SimplePie_File
|
||||
{
|
||||
if ($syslog_enabled)
|
||||
{
|
||||
syslog(LOG_INFO, 'SimplePie GET ' . $url); //FreshRSS
|
||||
syslog(LOG_INFO, 'SimplePie GET ' . SimplePie_Misc::url_remove_credentials($url)); //FreshRSS
|
||||
}
|
||||
if ($useragent === null)
|
||||
{
|
||||
|
||||
@@ -2240,5 +2240,15 @@ function embed_wmedia(width, height, link) {
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) //FreshRSS
|
||||
{
|
||||
return preg_replace('#(?<=//)[^/:@]+:[^/:@]+@#', '', $url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ function sanitizeHTML($data, $base = '') {
|
||||
function get_content_by_parsing ($url, $path) {
|
||||
require_once (LIB_PATH . '/lib_phpQuery.php');
|
||||
|
||||
Minz_Log::notice('FreshRSS GET ' . url_remove_credentials($url));
|
||||
Minz_Log::notice('FreshRSS GET ' . SimplePie_Misc::url_remove_credentials($url));
|
||||
$html = file_get_contents ($url);
|
||||
|
||||
if ($html) {
|
||||
@@ -430,13 +430,3 @@ 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('/[^\/]*:[^:]*@/', '', $url);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user