aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-05-21 19:15:55 -0700
committerFriendika <info@friendika.com>2011-05-21 19:15:55 -0700
commitf3f063c0dd7fd8b706987b856d79c7b58924acbb (patch)
treeae2de2b5046149d237292e426092d30b1537b9b2
parent1ccda19f7a0baae1d738891f9b73ff97242cbdff (diff)
downloadvolse-hubzilla-f3f063c0dd7fd8b706987b856d79c7b58924acbb.tar.gz
volse-hubzilla-f3f063c0dd7fd8b706987b856d79c7b58924acbb.tar.bz2
volse-hubzilla-f3f063c0dd7fd8b706987b856d79c7b58924acbb.zip
Drupal doesn't provide absolute URL on feed. Fix to allow importing Drupal "contacts".
-rw-r--r--include/Scrape.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/Scrape.php b/include/Scrape.php
index 21e6bd01f..7fc0c964b 100644
--- a/include/Scrape.php
+++ b/include/Scrape.php
@@ -241,6 +241,17 @@ function scrape_feed($url) {
}
}
+
+ $head = $dom->getElementsByTagName('base');
+ if($head) {
+ foreach($head as $head0) {
+ $basename = $head0->getAttribute('href');
+ break;
+ }
+ }
+ if(! $basename)
+ $basename = substr($url,0,strrpos($url,'/')) . '/';
+
$items = $dom->getElementsByTagName('link');
// get Atom/RSS link elements, take the first one of either.
@@ -259,6 +270,13 @@ function scrape_feed($url) {
}
}
+ // Drupal and perhaps others only provide relative URL's. Turn them into absolute.
+
+ if(x($ret,'feed_atom') && (! strstr($ret['feed_atom'],'://')))
+ $ret['feed_atom'] = $basename . $ret['feed_atom'];
+ if(x($ret,'feed_rss') && (! strstr($ret['feed_rss'],'://')))
+ $ret['feed_rss'] = $basename . $ret['feed_rss'];
+
return $ret;
}}