From 0f859c6f321af6dfaea66e04cde705ba97e6b5be Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Fri, 11 Apr 2014 17:21:54 +0300 Subject: error with empty content by import fixed. Also youtube and vimeo videos are allowd in content now. --- inc/poche/Database.class.php | 4 ++-- inc/poche/Poche.class.php | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) (limited to 'inc') diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php index d1044a6e..036c9d1b 100755 --- a/inc/poche/Database.class.php +++ b/inc/poche/Database.class.php @@ -245,7 +245,7 @@ class Database { $sql_limit = "LIMIT ".$limit." OFFSET 0"; } - $sql = "SELECT * FROM entries WHERE (content = '' OR content IS NULL) AND user_id=? ORDER BY id " . $sql_limit; + $sql = "SELECT * FROM entries WHERE (content = '' OR content IS NULL) AND title LIKE 'Untitled - Import%' AND user_id=? ORDER BY id " . $sql_limit; $query = $this->executeQuery($sql, array($user_id)); $entries = $query->fetchAll(); @@ -253,7 +253,7 @@ class Database { } public function retrieveUnfetchedEntriesCount($user_id) { - $sql = "SELECT count(*) FROM entries WHERE (content = '' OR content IS NULL) AND user_id=?"; + $sql = "SELECT count(*) FROM entries WHERE (content = '' OR content IS NULL) AND title LIKE 'Untitled - Import%' AND user_id=?"; $query = $this->executeQuery($sql, array($user_id)); list($count) = $query->fetch(); diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 3a4e78d6..811895dc 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php @@ -373,9 +373,7 @@ class Poche $body = $content['rss']['channel']['item']['description']; // clean content from prevent xss attack - $config = HTMLPurifier_Config::createDefault(); - $config->set('Cache.SerializerPath', CACHE); - $purifier = new HTMLPurifier($config); + $purifier = $this->getPurifier(); $title = $purifier->purify($title); $body = $purifier->purify($body); @@ -920,9 +918,7 @@ class Poche Tools::logm('Fetching next batch of articles...'); $items = $this->store->retrieveUnfetchedEntries($this->user->getId(), IMPORT_LIMIT); - $config = HTMLPurifier_Config::createDefault(); - $config->set('Cache.SerializerPath', CACHE); - $purifier = new HTMLPurifier($config); + $purifier = $this->getPurifier(); foreach ($items as $item) { $url = new Url(base64_encode($item['url'])); @@ -1064,4 +1060,16 @@ class Poche $this->messages->add('s', _('Cache deleted.')); Tools::redirect(); } + + /** + * return new purifier object with actual config + */ + protected function getPurifier() { + $config = HTMLPurifier_Config::createDefault(); + $config->set('Cache.SerializerPath', CACHE); + $config->set('HTML.SafeIframe', true); + $config->set('URI.SafeIframeRegexp', '%^(https?:)?//(www\.youtube(?:-nocookie)?\.com/embed/|player\.vimeo\.com/video/)%'); //allow YouTube and Vimeo$purifier = new HTMLPurifier($config); + + return new HTMLPurifier($config); + } } -- cgit v1.2.3