diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-07-25 01:04:25 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-07-25 01:04:25 +0200 |
commit | cd5b581c6a60893cdc1f8e32e793e86c08e5058e (patch) | |
tree | a4df4c62056887cc01767793ce4b23dce4706fc0 /utility | |
parent | eac8eca7a35fedb899312424d518f3b75269bad7 (diff) |
decode all the things twice
Diffstat (limited to 'utility')
-rw-r--r-- | utility/feedfetcher.php | 26 |
1 files changed, 12 insertions, 14 deletions
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 |