From c0e277cec84a3e26c95ac98a8b27246120030927 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 4 Oct 2015 00:28:15 +0200 Subject: [PATCH] Issue 1913: Report invalid feed --- include/Scrape.php | 5 +++-- include/gprobe.php | 2 +- include/identity.php | 2 +- include/socgraph.php | 2 +- mod/follow.php | 6 ++++++ 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/Scrape.php b/include/Scrape.php index 93d68be22b..5e26c461ae 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -652,9 +652,10 @@ function probe_url($url, $mode = PROBE_NORMAL, $level = 1) { $feed->set_raw_data(($xml) ? $xml : ''); $feed->init(); - if($feed->error()) + if($feed->error()) { logger('probe_url: scrape_feed: Error parsing XML: ' . $feed->error()); - + $network = NETWORK_PHANTOM; + } if(! x($vcard,'photo')) $vcard['photo'] = $feed->get_image_url(); diff --git a/include/gprobe.php b/include/gprobe.php index 03cdbd072b..84292f263a 100644 --- a/include/gprobe.php +++ b/include/gprobe.php @@ -47,7 +47,7 @@ function gprobe_run(&$argv, &$argc){ $result = Cache::get("gprobe:".$urlparts["host"]); if (!is_null($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); return; } diff --git a/include/identity.php b/include/identity.php index b4bc79e00f..6faddffd3c 100644 --- a/include/identity.php +++ b/include/identity.php @@ -710,7 +710,7 @@ function zrl_init(&$a) { $result = Cache::get("gprobe:".$urlparts["host"]); if (!is_null($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); return; } diff --git a/include/socgraph.php b/include/socgraph.php index d380af4344..b0f0c8672f 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -570,7 +570,7 @@ function poco_last_updated($profile, $force = 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'", dbesc(datetime_convert()), dbesc(normalise_link($profile))); return false; diff --git a/mod/follow.php b/mod/follow.php index bdcde77435..dd717aacd9 100755 --- a/mod/follow.php +++ b/mod/follow.php @@ -31,6 +31,12 @@ function follow_content(&$a) { $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) $ret["url"] = $ret["addr"]; -- 2.39.5