mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2026-02-07 23:01:33 +00:00
parser: clean() attribute values by default (except content)
This commit is contained in:
@@ -31,20 +31,20 @@ abstract class FeedItem_Common extends FeedItem {
|
||||
if ($author) {
|
||||
$name = $author->getElementsByTagName("name")->item(0);
|
||||
|
||||
if ($name) return $name->nodeValue;
|
||||
if ($name) return clean($name->nodeValue);
|
||||
|
||||
$email = $author->getElementsByTagName("email")->item(0);
|
||||
|
||||
if ($email) return $email->nodeValue;
|
||||
if ($email) return clean($email->nodeValue);
|
||||
|
||||
if ($author->nodeValue)
|
||||
return $author->nodeValue;
|
||||
return clean($author->nodeValue);
|
||||
}
|
||||
|
||||
$author = $this->xpath->query("dc:creator", $this->elem)->item(0);
|
||||
|
||||
if ($author) {
|
||||
return $author->nodeValue;
|
||||
return clean($author->nodeValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,15 +53,15 @@ abstract class FeedItem_Common extends FeedItem {
|
||||
//might give a wrong result if a default namespace was declared (possible with XPath 2.0)
|
||||
$com_url = $this->xpath->query("comments", $this->elem)->item(0);
|
||||
|
||||
if($com_url)
|
||||
return $com_url->nodeValue;
|
||||
if ($com_url)
|
||||
return clean($com_url->nodeValue);
|
||||
|
||||
//Atom Threading Extension (RFC 4685) stuff. Could be used in RSS feeds, so it's in common.
|
||||
//'text/html' for type is too restrictive?
|
||||
$com_url = $this->xpath->query("atom:link[@rel='replies' and contains(@type,'text/html')]/@href", $this->elem)->item(0);
|
||||
|
||||
if($com_url)
|
||||
return $com_url->nodeValue;
|
||||
if ($com_url)
|
||||
return clean($com_url->nodeValue);
|
||||
}
|
||||
|
||||
function get_comments_count() {
|
||||
@@ -70,7 +70,7 @@ abstract class FeedItem_Common extends FeedItem {
|
||||
$comments = $this->xpath->query($query, $this->elem)->item(0);
|
||||
|
||||
if ($comments) {
|
||||
return $comments->nodeValue;
|
||||
return clean($comments->nodeValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +83,19 @@ abstract class FeedItem_Common extends FeedItem {
|
||||
foreach ($enclosures as $enclosure) {
|
||||
$enc = new FeedEnclosure();
|
||||
|
||||
$enc->type = $enclosure->getAttribute("type");
|
||||
$enc->link = $enclosure->getAttribute("url");
|
||||
$enc->length = $enclosure->getAttribute("length");
|
||||
$enc->height = $enclosure->getAttribute("height");
|
||||
$enc->width = $enclosure->getAttribute("width");
|
||||
$enc->type = clean($enclosure->getAttribute("type"));
|
||||
$enc->link = clean($enclosure->getAttribute("url"));
|
||||
$enc->length = clean($enclosure->getAttribute("length"));
|
||||
$enc->height = clean($enclosure->getAttribute("height"));
|
||||
$enc->width = clean($enclosure->getAttribute("width"));
|
||||
|
||||
$medium = $enclosure->getAttribute("medium");
|
||||
$medium = clean($enclosure->getAttribute("medium"));
|
||||
if (!$enc->type && $medium) {
|
||||
$enc->type = strtolower("$medium/generic");
|
||||
}
|
||||
|
||||
$desc = $this->xpath->query("media:description", $enclosure)->item(0);
|
||||
if ($desc) $enc->title = strip_tags($desc->nodeValue);
|
||||
if ($desc) $enc->title = clean($desc->nodeValue);
|
||||
|
||||
array_push($encs, $enc);
|
||||
}
|
||||
@@ -108,23 +108,23 @@ abstract class FeedItem_Common extends FeedItem {
|
||||
$content = $this->xpath->query("media:content", $enclosure)->item(0);
|
||||
|
||||
if ($content) {
|
||||
$enc->type = $content->getAttribute("type");
|
||||
$enc->link = $content->getAttribute("url");
|
||||
$enc->length = $content->getAttribute("length");
|
||||
$enc->height = $content->getAttribute("height");
|
||||
$enc->width = $content->getAttribute("width");
|
||||
$enc->type = clean($content->getAttribute("type"));
|
||||
$enc->link = clean($content->getAttribute("url"));
|
||||
$enc->length = clean($content->getAttribute("length"));
|
||||
$enc->height = clean($content->getAttribute("height"));
|
||||
$enc->width = clean($content->getAttribute("width"));
|
||||
|
||||
$medium = $content->getAttribute("medium");
|
||||
$medium = clean($content->getAttribute("medium"));
|
||||
if (!$enc->type && $medium) {
|
||||
$enc->type = strtolower("$medium/generic");
|
||||
}
|
||||
|
||||
$desc = $this->xpath->query("media:description", $content)->item(0);
|
||||
if ($desc) {
|
||||
$enc->title = strip_tags($desc->nodeValue);
|
||||
$enc->title = clean($desc->nodeValue);
|
||||
} else {
|
||||
$desc = $this->xpath->query("media:description", $enclosure)->item(0);
|
||||
if ($desc) $enc->title = strip_tags($desc->nodeValue);
|
||||
if ($desc) $enc->title = clean($desc->nodeValue);
|
||||
}
|
||||
|
||||
array_push($encs, $enc);
|
||||
@@ -137,9 +137,9 @@ abstract class FeedItem_Common extends FeedItem {
|
||||
$enc = new FeedEnclosure();
|
||||
|
||||
$enc->type = "image/generic";
|
||||
$enc->link = $enclosure->getAttribute("url");
|
||||
$enc->height = $enclosure->getAttribute("height");
|
||||
$enc->width = $enclosure->getAttribute("width");
|
||||
$enc->link = clean($enclosure->getAttribute("url"));
|
||||
$enc->height = clean($enclosure->getAttribute("height"));
|
||||
$enc->width = clean($enclosure->getAttribute("width"));
|
||||
|
||||
array_push($encs, $enc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user