From 881b7d973373b432155f664003e7e54fe6db7266 Mon Sep 17 00:00:00 2001 From: Aleteoryx Date: Thu, 14 Nov 2024 16:50:04 -0500 Subject: default content to '', rename render_mode to mode --- rss.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'rss.php') diff --git a/rss.php b/rss.php index b75640f..4468a7d 100644 --- a/rss.php +++ b/rss.php @@ -1,11 +1,11 @@ getElementsByTagName("description") - ?->item(0)?->textContent; + ?->item(0)?->textContent??""; if ($allow_html === TRUE || $allow_html === NULL) { $data["content"] = strip_html($data["content"]); } else { @@ -109,7 +109,7 @@ function load_rss(string $uri, string $linkrel = "alternate", ?bool $allow_html $data["title"] = htmlentities(html_entity_decode($data["title"])); $data["content"] = $node->getElementsByTagName("content") - ?->item(0)?->textContent; + ?->item(0)?->textContent??""; if ($node->getElementsByTagName("content") ?->item(0) @@ -162,6 +162,8 @@ function load_cached(int $ttl, string $uri, string $linkrel = "alternate", ?bool // TODO: sniff for 8.4 Dom\HTMLDocument when 8.4 releases // function strip_html(string $html): string { + if ($html === "") return $html; + $doc = new DomDocument(); @$doc->loadHTML($html); @@ -177,6 +179,8 @@ function strip_html(string $html): string { $el->setAttribute("javascript:alert('Link stripped for security.')"); if (str_starts_with($el->getAttribute("src"), "javascript:")) $el->setAttribute("javascript:alert('Link stripped for security.')"); + + @$el->removeAttribute("autoplay"); } return implode( @@ -213,16 +217,16 @@ foreach ($feeds as $name => $data) { if (!isset($data["ttl"])) $data["ttl"] = 3600; if (!isset($data["linkrel"])) $data["linkrel"] = "alternate"; - $data["render_mode"] ??= "title"; + $data["mode"] ??= "title"; foreach(load_cached($data["ttl"], $data["url"], $data["linkrel"], @$data["allow_html"]) as $entry) { $entry["source"] = htmlentities($name); $entry["home"] = htmlentities(@$data["home"]); - if ($data["render_mode"] == "title") { + if ($data["mode"] == "title") { unset($entry["content"]); } - if ($data["render_mode"] == "no_title") { + if ($data["mode"] == "no_title") { unset($entry["title"]); } -- cgit v1.2.3-54-g00ecf