Merge branch 'master' of git://github.com/syrnon/Tiny-Tiny-RSS into syrnon-master
This commit is contained in:
commit
940e29a637
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
class FeedItem_Atom extends FeedItem_Common {
|
||||
|
||||
function get_id() {
|
||||
$id = $this->elem->getElementsByTagName("id")->item(0);
|
||||
|
||||
|
@ -30,6 +31,35 @@ class FeedItem_Atom extends FeedItem_Common {
|
|||
}
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
|
@ -38,8 +68,8 @@ class FeedItem_Atom extends FeedItem_Common {
|
|||
(!$link->hasAttribute("rel")
|
||||
|| $link->getAttribute("rel") == "alternate"
|
||||
|| $link->getAttribute("rel") == "standout")) {
|
||||
|
||||
return $link->getAttribute("href");
|
||||
$base = $this->xpath->evaluate("string(ancestor-or-self::*[@xml:base][1]/@xml:base)",$link);
|
||||
return $this->rel2abs($link->getAttribute("href"), $base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue