mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-17 14:18:35 +01:00
[FormatAbstract]: Ensure sanitizeHtml is given string (#2791)
Sometimes `Item::getContent` returns `null`, in which case `sanitizeHtml` would pass it to `str_replace`, which would raise `E_DEPRECATED` on PHP 8.1.
This commit is contained in:
parent
9ac494b350
commit
10eb1c9a95
@ -49,7 +49,7 @@ class JsonFormat extends FormatAbstract {
|
||||
$entryTitle = $item->getTitle();
|
||||
$entryUri = $item->getURI();
|
||||
$entryTimestamp = $item->getTimestamp();
|
||||
$entryContent = $this->sanitizeHtml($item->getContent());
|
||||
$entryContent = $item->getContent() ? $this->sanitizeHtml($item->getContent()) : '';
|
||||
$entryEnclosures = $item->getEnclosures();
|
||||
$entryCategories = $item->getCategories();
|
||||
|
||||
|
@ -100,7 +100,7 @@ class MrssFormat extends FormatAbstract {
|
||||
$itemTimestamp = $item->getTimestamp();
|
||||
$itemTitle = $item->getTitle();
|
||||
$itemUri = $item->getURI();
|
||||
$itemContent = $this->sanitizeHtml($item->getContent());
|
||||
$itemContent = $item->getContent() ? $this->sanitizeHtml($item->getContent()) : '';
|
||||
$entryID = $item->getUid();
|
||||
$isPermaLink = 'false';
|
||||
|
||||
|
@ -130,7 +130,7 @@ abstract class FormatAbstract implements FormatInterface {
|
||||
* @todo Maybe switch to http://htmlpurifier.org/
|
||||
* @todo Maybe switch to http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/index.php
|
||||
*/
|
||||
protected function sanitizeHtml($html)
|
||||
protected function sanitizeHtml(string $html): string
|
||||
{
|
||||
$html = str_replace('<script', '<‌script', $html); // Disable scripts, but leave them visible.
|
||||
$html = str_replace('<iframe', '<‌iframe', $html);
|
||||
|
Loading…
x
Reference in New Issue
Block a user