From cd5b581c6a60893cdc1f8e32e793e86c08e5058e Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Thu, 25 Jul 2013 01:04:25 +0200 Subject: decode all the things twice --- utility/feedfetcher.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'utility') diff --git a/utility/feedfetcher.php b/utility/feedfetcher.php index 217723d83..a4e9b25ce 100644 --- a/utility/feedfetcher.php +++ b/utility/feedfetcher.php @@ -111,21 +111,21 @@ class FeedFetcher implements IFeedFetcher { } + private function decodeTwice($string) { + return html_entity_decode( + html_entity_decode($string, ENT_COMPAT, 'UTF-8'), ENT_COMPAT, 'UTF-8' + ); + } + + protected function buildItem($simplePieItem) { $item = new Item(); $item->setStatus(0); $item->setUnread(); - $item->setUrl( - html_entity_decode($simplePieItem->get_permalink(), ENT_COMPAT, 'UTF-8') - ); + $item->setUrl($this->decodeTwice($simplePieItem->get_permalink())); // unescape content because angularjs helps against XSS - // unescape again to clean up stuff that was escaped - $item->setTitle( - html_entity_decode( - html_entity_decode($simplePieItem->get_title(), ENT_COMPAT, 'UTF-8'), - ENT_COMPAT, 'UTF-8') - ); + $item->setTitle($this->decodeTwice($simplePieItem->get_title())); $guid = $simplePieItem->get_id(); $item->setGuid($guid); $item->setGuidHash(md5($guid)); @@ -151,13 +151,11 @@ class FeedFetcher implements IFeedFetcher { $author = $simplePieItem->get_author(); if ($author !== null) { - $name = html_entity_decode($author->get_name(), - ENT_COMPAT, 'UTF-8' ); + $name = $this->decodeTwice($author->get_name()); if ($name) { $item->setAuthor($name); } else { - $item->setAuthor(html_entity_decode($author->get_email()), - ENT_COMPAT, 'UTF-8' ); + $item->setAuthor($this->decodeTwice($author->get_email())); } } @@ -179,7 +177,7 @@ class FeedFetcher implements IFeedFetcher { $feed = new Feed(); // unescape content because angularjs helps against XSS - $title = html_entity_decode($simplePieFeed->get_title(), + $title = $this->decodeTwice($simplePieFeed->get_title(), ENT_COMPAT, 'UTF-8' ); // if there is no title use the url -- cgit v1.2.3