Merge pull request #1928 from annando/issue-1913

Issue 1913: Report invalid feed
This commit is contained in:
Tobias Diekershoff 2015-10-04 08:54:59 +02:00
commit be70dde61f
5 changed files with 12 additions and 5 deletions

View file

@ -652,9 +652,10 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
$feed->set_raw_data(($xml) ? $xml : '<?xml version="1.0" encoding="utf-8" ?><xml></xml>'); $feed->set_raw_data(($xml) ? $xml : '<?xml version="1.0" encoding="utf-8" ?><xml></xml>');
$feed->init(); $feed->init();
if($feed->error()) if($feed->error()) {
logger('probe_url: scrape_feed: Error parsing XML: ' . $feed->error()); logger('probe_url: scrape_feed: Error parsing XML: ' . $feed->error());
$network = NETWORK_PHANTOM;
}
if(! x($vcard,'photo')) if(! x($vcard,'photo'))
$vcard['photo'] = $feed->get_image_url(); $vcard['photo'] = $feed->get_image_url();

View file

@ -47,7 +47,7 @@ function gprobe_run(&$argv, &$argc){
$result = Cache::get("gprobe:".$urlparts["host"]); $result = Cache::get("gprobe:".$urlparts["host"]);
if (!is_null($result)) { if (!is_null($result)) {
$result = unserialize($result); $result = unserialize($result);
if ($result["network"] == NETWORK_FEED) { if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG); logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
return; return;
} }

View file

@ -710,7 +710,7 @@ function zrl_init(&$a) {
$result = Cache::get("gprobe:".$urlparts["host"]); $result = Cache::get("gprobe:".$urlparts["host"]);
if (!is_null($result)) { if (!is_null($result)) {
$result = unserialize($result); $result = unserialize($result);
if ($result["network"] == NETWORK_FEED) { if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) {
logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG); logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG);
return; return;
} }

View file

@ -570,7 +570,7 @@ function poco_last_updated($profile, $force = false) {
return false; return false;
} }
if (($data["poll"] == "") OR ($data["network"] == NETWORK_FEED)) { if (($data["poll"] == "") OR (in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM)))) {
q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'", q("UPDATE `gcontact` SET `last_failure` = '%s' WHERE `nurl` = '%s'",
dbesc(datetime_convert()), dbesc(normalise_link($profile))); dbesc(datetime_convert()), dbesc(normalise_link($profile)));
return false; return false;

View file

@ -31,6 +31,12 @@ function follow_content(&$a) {
$ret = probe_url($url); $ret = probe_url($url);
if ($ret["network"] == NETWORK_PHANTOM) {
notice( t("The network type couldn't be detected. Contact can't be added.") . EOL);
goaway($_SESSION['return_url']);
// NOTREACHED
}
if ($ret["network"] == NETWORK_MAIL) if ($ret["network"] == NETWORK_MAIL)
$ret["url"] = $ret["addr"]; $ret["url"] = $ret["addr"];