summaryrefslogtreecommitdiff
path: root/classes/feeditem
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-07-11 14:21:29 +0400
committerAndrew Dolgov <[email protected]>2013-07-11 14:21:29 +0400
commit3c4dead676a7c5199aef1b022f54f7763c17311e (patch)
treee87b5563f73c51a7f6d3a760889736bf5612a063 /classes/feeditem
parent940e29a63789111c813d5c2d88c0e30071b113f0 (diff)
atom: remove rel2abs; use rewrite_relative_url
Diffstat (limited to 'classes/feeditem')
-rw-r--r--classes/feeditem/atom.php37
1 files changed, 5 insertions, 32 deletions
diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php
index 532c599cc..f82c582da 100644
--- a/classes/feeditem/atom.php
+++ b/classes/feeditem/atom.php
@@ -30,36 +30,8 @@ class FeedItem_Atom extends FeedItem_Common {
return strtotime($date->nodeValue);
}
}
-
- function rel2abs($rel, $base)
- {
- /* return if already absolute URL */
- if (parse_url($rel, PHP_URL_SCHEME) != '') return $rel;
-
- /* queries and anchors */
- if ($rel[0]=='#' || $rel[0]=='?') return $base.$rel;
-
- /* parse base URL and convert to local variables:
- $scheme, $host, $path */
- extract(parse_url($base));
-
- /* remove non-directory element from path */
- $path = preg_replace('#/[^/]*$#', '', $path);
-
- /* destroy path if relative url points to root */
- if ($rel[0] == '/') $path = '';
-
- /* dirty absolute URL */
- $abs = "$host$path/$rel";
-
- /* replace '//' or '/./' or '/foo/../' with '/' */
- $re = array('#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#');
- for($n=1; $n>0; $abs=preg_replace($re, '/', $abs, -1, $n)) {}
-
- /* absolute URL is ready! */
- return $scheme.'://'.$abs;
- }
-
+
+
function get_link() {
$links = $this->elem->getElementsByTagName("link");
@@ -68,8 +40,9 @@ class FeedItem_Atom extends FeedItem_Common {
(!$link->hasAttribute("rel")
|| $link->getAttribute("rel") == "alternate"
|| $link->getAttribute("rel") == "standout")) {
- $base = $this->xpath->evaluate("string(ancestor-or-self::*[@xml:base][1]/@xml:base)",$link);
- return $this->rel2abs($link->getAttribute("href"), $base);
+ $base = $this->xpath->evaluate("string(ancestor-or-self::*[@xml:base][1]/@xml:base)", $link);
+
+ return rewrite_relative_url($base, $link->getAttribute("href"));
}
}
}