From a6324c47a033c59beda4048c6f10f0791bd7cf04 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 24 Feb 2013 14:03:14 -0500 Subject: [PATCH] Update vendor --- src/vendor/PicoFeed/Filter.php | 19 ++++++++++++++ src/vendor/PicoFeed/Reader.php | 45 +++++++++++++++++++++------------ src/vendor/PicoTools/Helper.php | 6 +++++ 3 files changed, 54 insertions(+), 16 deletions(-) diff --git a/src/vendor/PicoFeed/Filter.php b/src/vendor/PicoFeed/Filter.php index f11ab5c..3853bbd 100644 --- a/src/vendor/PicoFeed/Filter.php +++ b/src/vendor/PicoFeed/Filter.php @@ -13,6 +13,16 @@ class Filter public $ignored_tags = array(); public $allowed_tags = array( + 'dt' => array(), + 'dd' => array(), + 'dl' => array(), + 'table' => array(), + 'caption' => array(), + 'tr' => array(), + 'th' => array(), + 'td' => array(), + 'tbody' => array(), + 'thead' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), @@ -63,6 +73,10 @@ class Filter 'img' => array('src') ); + public $add_attributes = array( + 'a' => 'rel="noreferrer" target="_blank"' + ); + public function __construct($data, $url) { @@ -150,6 +164,11 @@ class Filter $this->data .= '<'.$name.$attr_data; + if (isset($this->add_attributes[$name])) { + + $this->data .= ' '.$this->add_attributes[$name].' '; + } + if ($name !== 'img' && $name !== 'br') $this->data .= '>'; } } diff --git a/src/vendor/PicoFeed/Reader.php b/src/vendor/PicoFeed/Reader.php index 2edb38f..5e62a87 100644 --- a/src/vendor/PicoFeed/Reader.php +++ b/src/vendor/PicoFeed/Reader.php @@ -42,34 +42,42 @@ class Reader } - public function getParser() + public function getFirstTag($data) { - $first_lines = substr($this->content, 0, 1024); + if (strpos($data, '') + 2); - if ($this->discover()) { + $open_tag = strpos($data, '<'); + $close_tag = strpos($data, '>'); - $first_lines = substr($this->content, 0, 1024); - } - else { - - return false; - } + return substr($data, $open_tag, $close_tag); } - if (strpos($first_lines, 'getFirstTag($this->content); + + if (strpos($first_tag, 'content); } - else if (strpos($first_lines, 'content); - }/* - else if (strpos($first_lines, 'content); - }*/ + return false; + } + else if ($this->discover()) { + + return $this->getParser(true); + } return false; } @@ -77,6 +85,11 @@ class Reader public function discover() { + if (! $this->content) { + + return false; + } + \libxml_use_internal_errors(true); $dom = new \DOMDocument; diff --git a/src/vendor/PicoTools/Helper.php b/src/vendor/PicoTools/Helper.php index 86fafd8..d0ab0ff 100644 --- a/src/vendor/PicoTools/Helper.php +++ b/src/vendor/PicoTools/Helper.php @@ -49,6 +49,12 @@ function flash_error($html) } +function get_host_from_url($url) +{ + return escape(parse_url($url, PHP_URL_HOST)); +} + + function in_list($id, array $listing) { if (isset($listing[$id])) {