From: wn_ Date: Sat, 9 Sep 2017 18:51:59 +0000 (-0500) Subject: Use 'saveHTML' when generating HTML from a DOMDocument. X-Git-Tag: 17.12~128^2 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=f3774b9d65cdd189d9caeac8066b8a3e27c5d549;p=tt-rss.git Use 'saveHTML' when generating HTML from a DOMDocument. This primarily occurs when modifying article content. If 'saveXML' is used following 'loadHTML' there is the possibility of strangeness, such as a self-closing anchor tag. Note that the DOMDocument used in 'classes/feeditem/atom.php' came from 'loadXML', but we use 'saveHTML' since we're returning HTML content. --- diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index 76d85b2a..77cd448b 100644 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -69,7 +69,7 @@ class FeedItem_Atom extends FeedItem_Common { $child = $content->childNodes->item($i); if ($child->hasChildNodes()) { - return $this->doc->saveXML($child); + return $this->doc->saveHTML($child); } } } @@ -89,7 +89,7 @@ class FeedItem_Atom extends FeedItem_Common { $child = $content->childNodes->item($i); if ($child->hasChildNodes()) { - return $this->doc->saveXML($child); + return $this->doc->saveHTML($child); } } } @@ -197,4 +197,4 @@ class FeedItem_Atom extends FeedItem_Common { return $encs; } -} \ No newline at end of file +} diff --git a/plugins/af_comics/filters/af_comics_cad.php b/plugins/af_comics/filters/af_comics_cad.php index 6846f3cb..d2eb38ca 100644 --- a/plugins/af_comics/filters/af_comics_cad.php +++ b/plugins/af_comics/filters/af_comics_cad.php @@ -25,7 +25,7 @@ class Af_Comics_Cad extends Af_ComicFilter { $basenode = $xpath->query('//div[@class="comicpage"]/a/img')->item(0); if ($basenode) { - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); } } @@ -36,4 +36,4 @@ class Af_Comics_Cad extends Af_ComicFilter { return false; } -} \ No newline at end of file +} diff --git a/plugins/af_comics/filters/af_comics_comicclass.php b/plugins/af_comics/filters/af_comics_comicclass.php index 56a5b9cf..b4b3a962 100644 --- a/plugins/af_comics/filters/af_comics_comicclass.php +++ b/plugins/af_comics/filters/af_comics_comicclass.php @@ -22,7 +22,7 @@ class Af_Comics_ComicClass extends Af_ComicFilter { $basenode = $xpath->query('//div[@class="comic"]')->item(0); if ($basenode) { - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); } } @@ -31,4 +31,4 @@ class Af_Comics_ComicClass extends Af_ComicFilter { return false; } -} \ No newline at end of file +} diff --git a/plugins/af_comics/filters/af_comics_comicpress.php b/plugins/af_comics/filters/af_comics_comicpress.php index 81994d90..51d9bab3 100644 --- a/plugins/af_comics/filters/af_comics_comicpress.php +++ b/plugins/af_comics/filters/af_comics_comicpress.php @@ -27,7 +27,7 @@ class Af_Comics_ComicPress extends Af_ComicFilter { $basenode = $xpath->query('//div[@id="comic"]')->item(0); if ($basenode) { - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); } } @@ -36,4 +36,4 @@ class Af_Comics_ComicPress extends Af_ComicFilter { return false; } -} \ No newline at end of file +} diff --git a/plugins/af_comics/filters/af_comics_darklegacy.php b/plugins/af_comics/filters/af_comics_darklegacy.php index 33c1eca5..0882514d 100644 --- a/plugins/af_comics/filters/af_comics_darklegacy.php +++ b/plugins/af_comics/filters/af_comics_darklegacy.php @@ -26,7 +26,7 @@ class Af_Comics_DarkLegacy extends Af_ComicFilter { if ($basenode) { - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); } } @@ -35,4 +35,4 @@ class Af_Comics_DarkLegacy extends Af_ComicFilter { return false; } -} \ No newline at end of file +} diff --git a/plugins/af_comics/filters/af_comics_dilbert.php b/plugins/af_comics/filters/af_comics_dilbert.php index 565b4465..a40f8a9b 100644 --- a/plugins/af_comics/filters/af_comics_dilbert.php +++ b/plugins/af_comics/filters/af_comics_dilbert.php @@ -49,7 +49,7 @@ class Af_Comics_Dilbert extends Af_ComicFilter { } if ($basenode) { - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); } // Add comic title to article type if not empty (mostly Sunday strips) diff --git a/plugins/af_comics/filters/af_comics_explosm.php b/plugins/af_comics/filters/af_comics_explosm.php index 35a2edd4..c47014da 100644 --- a/plugins/af_comics/filters/af_comics_explosm.php +++ b/plugins/af_comics/filters/af_comics_explosm.php @@ -16,7 +16,7 @@ class Af_Comics_Explosm extends Af_ComicFilter { $basenode = $xpath->query('(//img[@id="main-comic"])')->item(0); if ($basenode) { - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); } } @@ -25,4 +25,4 @@ class Af_Comics_Explosm extends Af_ComicFilter { return false; } -} \ No newline at end of file +} diff --git a/plugins/af_comics/filters/af_comics_pa.php b/plugins/af_comics/filters/af_comics_pa.php index ae5cabec..e6558d8d 100644 --- a/plugins/af_comics/filters/af_comics_pa.php +++ b/plugins/af_comics/filters/af_comics_pa.php @@ -19,7 +19,7 @@ class Af_Comics_Pa extends Af_ComicFilter { $basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0); if ($basenode) { - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); } } @@ -62,7 +62,7 @@ class Af_Comics_Pa extends Af_ComicFilter { } if ($basenode){ - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); } } @@ -71,4 +71,4 @@ class Af_Comics_Pa extends Af_ComicFilter { return false; } -} \ No newline at end of file +} diff --git a/plugins/af_comics/filters/af_comics_pvp.php b/plugins/af_comics/filters/af_comics_pvp.php index 1a1ccab3..cf0b79d7 100644 --- a/plugins/af_comics/filters/af_comics_pvp.php +++ b/plugins/af_comics/filters/af_comics_pvp.php @@ -19,7 +19,7 @@ class Af_Comics_Pvp extends Af_ComicFilter { $basenode = $xpath->query('//section[@class="comic-art"]')->item(0); if ($basenode) { - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); } } @@ -28,4 +28,4 @@ class Af_Comics_Pvp extends Af_ComicFilter { return false; } -} \ No newline at end of file +} diff --git a/plugins/af_comics/filters/af_comics_tfd.php b/plugins/af_comics/filters/af_comics_tfd.php index 78792d25..376ec071 100644 --- a/plugins/af_comics/filters/af_comics_tfd.php +++ b/plugins/af_comics/filters/af_comics_tfd.php @@ -21,7 +21,7 @@ class Af_Comics_Tfd extends Af_ComicFilter { $basenode = $xpath->query('//img[contains(@src, ".gif")]')->item(0); if ($basenode) { - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); return true; } } @@ -29,4 +29,4 @@ class Af_Comics_Tfd extends Af_ComicFilter { return false; } -} \ No newline at end of file +} diff --git a/plugins/af_comics/filters/af_comics_twp.php b/plugins/af_comics/filters/af_comics_twp.php index 712d54a1..f53b89b6 100644 --- a/plugins/af_comics/filters/af_comics_twp.php +++ b/plugins/af_comics/filters/af_comics_twp.php @@ -17,7 +17,7 @@ class Af_Comics_Twp extends Af_ComicFilter { $basenode = $xpath->query("//td/center/img")->item(0); if ($basenode) { - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); } } @@ -26,4 +26,4 @@ class Af_Comics_Twp extends Af_ComicFilter { return false; } -} \ No newline at end of file +} diff --git a/plugins/af_comics/filters/af_comics_whomp.php b/plugins/af_comics/filters/af_comics_whomp.php index 3c2e0b0c..d574bf5d 100644 --- a/plugins/af_comics/filters/af_comics_whomp.php +++ b/plugins/af_comics/filters/af_comics_whomp.php @@ -24,7 +24,7 @@ class Af_Comics_Whomp extends Af_ComicFilter { $basenode = $xpath->query('//img[@id="cc-comic"]')->item(0); if ($basenode) { - $article["content"] = $doc->saveXML($basenode); + $article["content"] = $doc->saveHTML($basenode); } } @@ -33,4 +33,4 @@ class Af_Comics_Whomp extends Af_ComicFilter { return false; } -} \ No newline at end of file +} diff --git a/plugins/af_comics/init.php b/plugins/af_comics/init.php index 09e90337..6bd3c23e 100644 --- a/plugins/af_comics/init.php +++ b/plugins/af_comics/init.php @@ -127,7 +127,7 @@ class Af_Comics extends Plugin { $tpl->setVariable('ARTICLE_LINK', $article_link, true); $tpl->setVariable('ARTICLE_TITLE', date('l, F d, Y'), true); $tpl->setVariable('ARTICLE_EXCERPT', '', true); - $tpl->setVariable('ARTICLE_CONTENT', $doc->saveXML($node), true); + $tpl->setVariable('ARTICLE_CONTENT', $doc->saveHTML($node), true); $tpl->setVariable('ARTICLE_AUTHOR', '', true); $tpl->setVariable('ARTICLE_SOURCE_LINK', $site_url, true); @@ -153,4 +153,4 @@ class Af_Comics extends Plugin { return 2; } -} \ No newline at end of file +} diff --git a/plugins/af_fsckportal/init.php b/plugins/af_fsckportal/init.php index 40ace502..0fa58e9e 100644 --- a/plugins/af_fsckportal/init.php +++ b/plugins/af_fsckportal/init.php @@ -37,7 +37,7 @@ class Af_Fsckportal extends Plugin { } } - $article["content"] = $doc->saveXML(); + $article["content"] = $doc->saveHTML(); } @@ -48,4 +48,4 @@ class Af_Fsckportal extends Plugin { return 2; } -} \ No newline at end of file +} diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index d08dfa7a..ac23a4fa 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -364,7 +364,7 @@ class Af_RedditImgur extends Plugin { $node = $doc->getElementsByTagName('body')->item(0); if ($node && $found) { - $article["content"] = $doc->saveXML($node); + $article["content"] = $doc->saveHTML($node); } else if ($content_link) { $article = $this->readability($article, $content_link->getAttribute("href"), $doc, $xpath); } diff --git a/plugins/af_zz_imgproxy/init.php b/plugins/af_zz_imgproxy/init.php index c3b3f7fd..41fec4ac 100644 --- a/plugins/af_zz_imgproxy/init.php +++ b/plugins/af_zz_imgproxy/init.php @@ -199,7 +199,7 @@ class Af_Zz_ImgProxy extends Plugin { } } - if ($need_saving) $article["content"] = $doc->saveXML(); + if ($need_saving) $article["content"] = $doc->saveHTML(); return $article; } @@ -257,4 +257,4 @@ class Af_Zz_ImgProxy extends Plugin { function api_version() { return 2; } -} \ No newline at end of file +}