* @maintainer Brion Vibber <brion@status.net>
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET')) {
+ exit(1);
+}
class FeedSubBadURLException extends FeedSubException
{
{
}
+class FeedSubNoSalmonException extends FeedSubException
+{
+}
+
class FeedSubBadXmlException extends FeedSubException
{
}
}
/**
- * Get the referenced PuSH hub link from an Atom feed.
+ * Get the referenced WebSub hub link from an Atom feed.
*
* @return mixed string or false
*/
try {
$client = new HTTPClient();
$response = $client->get($url);
- } catch (HTTP_Request2_Exception $e) {
+ } catch (Exception $e) {
common_log(LOG_ERR, __METHOD__ . " Failure for $url - " . $e->getMessage());
throw new FeedSubBadURLException($e->getMessage());
}
$type = $response->getHeader('Content-Type');
$isHtml = preg_match('!^(text/html|application/xhtml\+xml)!i', $type);
if ($isHtml) {
- $target = $this->discoverFromHTML($response->getUrl(), $response->getBody());
+ $target = $this->discoverFromHTML($response->getEffectiveUrl(), $response->getBody());
if (!$target) {
throw new FeedSubNoFeedException($url);
}
throw new FeedSubBadResponseException($response->getStatus());
}
- $sourceurl = $response->getUrl();
+ $sourceurl = $response->getEffectiveUrl();
$body = $response->getBody();
if (!$body) {
throw new FeedSubEmptyException($sourceurl);
*/
function discoverFromHTML($url, $body)
{
- // DOMDocument::loadHTML may throw warnings on unrecognized elements.
- $old = error_reporting(error_reporting() & ~E_WARNING);
+ // DOMDocument::loadHTML may throw warnings on unrecognized elements,
+ // and notices on unrecognized namespaces.
+ $old = error_reporting(error_reporting() & ~(E_WARNING | E_NOTICE));
$dom = new DOMDocument();
$ok = $dom->loadHTML($body);
error_reporting($old);