From 7f335a533dd26e2ff9b601ae3f0477915d7af25f Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Sun, 1 Mar 2015 19:56:11 +0100 Subject: [PATCH] update dependencies - fixes #336 --- models/item.php | 2 +- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 10 +- vendor/composer/installed.json | 94 +++++++------- .../fguillot/json-rpc/src/JsonRPC/Client.php | 12 +- .../picofeed/docs/feed-parsing.markdown | 20 +-- .../picofeed/docs/installation.markdown | 7 +- .../picofeed/lib/PicoFeed/Client/Curl.php | 13 +- .../picofeed/lib/PicoFeed/Client/Grabber.php | 10 +- .../lib/PicoFeed/Encoding/Encoding.php | 5 + .../lib/PicoFeed/Filter/Attribute.php | 22 +++- .../picofeed/lib/PicoFeed/Filter/Html.php | 16 ++- .../picofeed/lib/PicoFeed/Filter/Tag.php | 43 +++++- .../picofeed/lib/PicoFeed/Parser/Atom.php | 13 +- .../lib/PicoFeed/Parser/DateParser.php | 32 +++-- .../picofeed/lib/PicoFeed/Parser/Feed.php | 7 +- .../picofeed/lib/PicoFeed/Parser/Item.php | 7 +- .../picofeed/lib/PicoFeed/Parser/Rss10.php | 2 +- .../picofeed/lib/PicoFeed/Parser/Rss20.php | 6 +- .../lib/PicoFeed/Parser/XmlParser.php | 49 ++++++- .../lib/PicoFeed/Rules/.wired.com.php | 2 - .../picofeed/lib/PicoFeed/Rules/01net.com.php | 1 - .../lib/PicoFeed/Rules/journaldugeek.com.php | 3 - .../lib/PicoFeed/Rules/lejapon.fr.php | 1 - .../PicoFeed/Rules/smallhousebliss.com.php | 2 - .../lib/PicoFeed/Rules/spiegel.de.php | 2 +- .../lib/PicoFeed/Rules/techcrunch.com.php | 2 - .../lib/PicoFeed/Rules/undeadly.org.php | 1 - .../lib/PicoFeed/Rules/www.bbc.co.uk.php | 2 - .../lib/PicoFeed/Rules/www.cnn.com.php | 2 - .../lib/PicoFeed/Rules/www.lepoint.fr.php | 2 - .../lib/PicoFeed/Rules/www.npr.org.php | 2 - .../lib/PicoFeed/Rules/www.slate.fr.php | 2 - .../picofeed/tests/Client/ClientTest.php | 25 ++-- .../picofeed/tests/Client/CurlTest.php | 25 ++-- .../picofeed/tests/Client/StreamTest.php | 25 ++-- .../tests/Filter/AttributeFilterTest.php | 6 +- .../picofeed/tests/Filter/FilterTest.php | 3 +- .../picofeed/tests/Filter/HtmlFilterTest.php | 73 ++++------- .../picofeed/tests/Parser/AtomParserTest.php | 10 +- .../picofeed/tests/Parser/DateParserTest.php | 64 ++++----- .../picofeed/tests/Parser/Rss10ParserTest.php | 4 +- .../picofeed/tests/Parser/Rss20ParserTest.php | 19 ++- .../picofeed/tests/Parser/Rss91ParserTest.php | 4 +- .../picofeed/tests/Parser/Rss92ParserTest.php | 2 +- .../picofeed/tests/Parser/XmlParserTest.php | 13 ++ .../tests/fixtures/allgemeine-zeitung.xml | 122 ++++++++++++++++++ .../tests/fixtures/miniflux_favicon.ico | Bin 0 -> 16958 bytes .../src/SimpleValidator/Base.php | 19 +-- .../src/SimpleValidator/Validator.php | 18 +-- .../src/SimpleValidator/Validators/Alpha.php | 15 +-- .../Validators/AlphaNumeric.php | 15 +-- .../src/SimpleValidator/Validators/Date.php | 2 +- .../src/SimpleValidator/Validators/Email.php | 12 -- .../src/SimpleValidator/Validators/Equals.php | 17 +-- .../src/SimpleValidator/Validators/Exists.php | 25 +--- .../Validators/GreaterThan.php | 13 +- .../SimpleValidator/Validators/InArray.php | 9 -- .../SimpleValidator/Validators/Integer.php | 17 +-- .../src/SimpleValidator/Validators/Ip.php | 16 +-- .../src/SimpleValidator/Validators/Length.php | 17 +-- .../SimpleValidator/Validators/MacAddress.php | 23 +--- .../SimpleValidator/Validators/MaxLength.php | 18 +-- .../SimpleValidator/Validators/MinLength.php | 18 +-- .../SimpleValidator/Validators/NotEquals.php | 19 +-- .../SimpleValidator/Validators/NotInArray.php | 9 -- .../SimpleValidator/Validators/Numeric.php | 15 +-- .../src/SimpleValidator/Validators/Range.php | 16 --- .../SimpleValidator/Validators/Required.php | 15 +-- .../src/SimpleValidator/Validators/Unique.php | 74 ++++------- .../SimpleValidator/Validators/Version.php | 16 +-- .../tests/UniqueValidatorTest.php | 47 +------ 72 files changed, 587 insertions(+), 669 deletions(-) create mode 100644 vendor/fguillot/picofeed/tests/fixtures/allgemeine-zeitung.xml create mode 100644 vendor/fguillot/picofeed/tests/fixtures/miniflux_favicon.ico diff --git a/models/item.php b/models/item.php index cef8ba9..1205143 100644 --- a/models/item.php +++ b/models/item.php @@ -477,7 +477,7 @@ function update_all($feed_id, array $items) 'id' => $item->getId(), 'title' => $item->getTitle(), 'url' => $item->getUrl(), - 'updated' => $item->getDate(), + 'updated' => $item->getDate()->getTimestamp(), 'author' => $item->getAuthor(), 'content' => $nocontent ? '' : $item->getContent(), 'status' => 'unread', diff --git a/vendor/autoload.php b/vendor/autoload.php index 6452865..19750ad 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -4,4 +4,4 @@ require_once __DIR__ . '/composer' . '/autoload_real.php'; -return ComposerAutoloaderInita6340803ab9f5b44ecc7aa3f90f789c5::getLoader(); +return ComposerAutoloaderInit4a7335ffe176a1ef5c75eb89d06418db::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 9a4b93d..9f55a55 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInita6340803ab9f5b44ecc7aa3f90f789c5 +class ComposerAutoloaderInit4a7335ffe176a1ef5c75eb89d06418db { private static $loader; @@ -19,9 +19,9 @@ class ComposerAutoloaderInita6340803ab9f5b44ecc7aa3f90f789c5 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInita6340803ab9f5b44ecc7aa3f90f789c5', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit4a7335ffe176a1ef5c75eb89d06418db', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(); - spl_autoload_unregister(array('ComposerAutoloaderInita6340803ab9f5b44ecc7aa3f90f789c5', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit4a7335ffe176a1ef5c75eb89d06418db', 'loadClassLoader')); $map = require __DIR__ . '/autoload_namespaces.php'; foreach ($map as $namespace => $path) { @@ -42,14 +42,14 @@ class ComposerAutoloaderInita6340803ab9f5b44ecc7aa3f90f789c5 $includeFiles = require __DIR__ . '/autoload_files.php'; foreach ($includeFiles as $file) { - composerRequirea6340803ab9f5b44ecc7aa3f90f789c5($file); + composerRequire4a7335ffe176a1ef5c75eb89d06418db($file); } return $loader; } } -function composerRequirea6340803ab9f5b44ecc7aa3f90f789c5($file) +function composerRequire4a7335ffe176a1ef5c75eb89d06418db($file) { require $file; } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index f7acb35..b9d1ecb 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,43 +1,4 @@ [ - { - "name": "fguillot/simple-validator", - "version": "dev-master", - "version_normalized": "9999999-dev", - "source": { - "type": "git", - "url": "https://github.com/fguillot/simpleValidator.git", - "reference": "9e9502c88ce239901c0fee12a1f504948342ab42" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/fguillot/simpleValidator/zipball/9e9502c88ce239901c0fee12a1f504948342ab42", - "reference": "9e9502c88ce239901c0fee12a1f504948342ab42", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2015-01-21 02:00:33", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "SimpleValidator": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Frédéric Guillot", - "homepage": "http://fredericguillot.com" - } - ], - "description": "The most easy to use validator library for PHP :)", - "homepage": "https://github.com/fguillot/simpleValidator" - }, { "name": "fguillot/picodb", "version": "v0.0.2", @@ -116,6 +77,45 @@ "description": "Minimalist micro-framework", "homepage": "https://github.com/fguillot/picoFarad" }, + { + "name": "fguillot/simple-validator", + "version": "dev-master", + "version_normalized": "9999999-dev", + "source": { + "type": "git", + "url": "https://github.com/fguillot/simpleValidator.git", + "reference": "5ebdb6df4c5f3aa2539b633eb4ae94c9e8c4ada7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fguillot/simpleValidator/zipball/5ebdb6df4c5f3aa2539b633eb4ae94c9e8c4ada7", + "reference": "5ebdb6df4c5f3aa2539b633eb4ae94c9e8c4ada7", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2015-02-14 21:04:14", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "SimpleValidator": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frédéric Guillot", + "homepage": "http://fredericguillot.com" + } + ], + "description": "The most easy to use validator library for PHP :)", + "homepage": "https://github.com/fguillot/simpleValidator" + }, { "name": "fguillot/json-rpc", "version": "dev-master", @@ -123,18 +123,18 @@ "source": { "type": "git", "url": "https://github.com/fguillot/JsonRPC.git", - "reference": "514695af758060b2c89fd67c59a04ac5da91481a" + "reference": "d64090706507dccab53e35ad5fcf00ae2502c647" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fguillot/JsonRPC/zipball/514695af758060b2c89fd67c59a04ac5da91481a", - "reference": "514695af758060b2c89fd67c59a04ac5da91481a", + "url": "https://api.github.com/repos/fguillot/JsonRPC/zipball/d64090706507dccab53e35ad5fcf00ae2502c647", + "reference": "d64090706507dccab53e35ad5fcf00ae2502c647", "shasum": "" }, "require": { "php": ">=5.3.0" }, - "time": "2015-02-02 22:12:09", + "time": "2015-02-13 03:20:58", "type": "library", "installation-source": "dist", "autoload": { @@ -162,12 +162,12 @@ "source": { "type": "git", "url": "https://github.com/fguillot/picoFeed.git", - "reference": "c6f0742ccda390c81782f788e289cd5d8b555c3a" + "reference": "beac91bf7cda7057d470c495b6616ced44ef1936" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fguillot/picoFeed/zipball/c6f0742ccda390c81782f788e289cd5d8b555c3a", - "reference": "c6f0742ccda390c81782f788e289cd5d8b555c3a", + "url": "https://api.github.com/repos/fguillot/picoFeed/zipball/beac91bf7cda7057d470c495b6616ced44ef1936", + "reference": "beac91bf7cda7057d470c495b6616ced44ef1936", "shasum": "" }, "require": { @@ -178,7 +178,7 @@ "ext-xml": "*", "php": ">=5.3.0" }, - "time": "2015-02-06 02:06:33", + "time": "2015-03-01 18:36:28", "type": "library", "installation-source": "dist", "autoload": { diff --git a/vendor/fguillot/json-rpc/src/JsonRPC/Client.php b/vendor/fguillot/json-rpc/src/JsonRPC/Client.php index 03803af..37ab6d5 100644 --- a/vendor/fguillot/json-rpc/src/JsonRPC/Client.php +++ b/vendor/fguillot/json-rpc/src/JsonRPC/Client.php @@ -252,7 +252,7 @@ class Client public function getResult(array $payload) { if (isset($payload['error']['code'])) { - $this->handleRpcErrors($payload['error']['code']); + $this->handleRpcErrors($payload['error']); } return isset($payload['result']) ? $payload['result'] : null; @@ -264,15 +264,15 @@ class Client * @access public * @param integer $code */ - public function handleRpcErrors($code) + public function handleRpcErrors($error) { - switch ($code) { + switch ($error['code']) { case -32601: - throw new BadFunctionCallException('Procedure not found'); + throw new BadFunctionCallException('Procedure not found: '. $error['message']); case -32602: - throw new InvalidArgumentException('Invalid arguments'); + throw new InvalidArgumentException('Invalid arguments: '. $error['message']); default: - throw new RuntimeException('Invalid request/response'); + throw new RuntimeException('Invalid request/response: '. $error['message'], $error['code']); } } diff --git a/vendor/fguillot/picofeed/docs/feed-parsing.markdown b/vendor/fguillot/picofeed/docs/feed-parsing.markdown index d00e083..6e7f2fd 100644 --- a/vendor/fguillot/picofeed/docs/feed-parsing.markdown +++ b/vendor/fguillot/picofeed/docs/feed-parsing.markdown @@ -45,23 +45,23 @@ Feed::id = tag:linuxfr.org,2005:/news Feed::title = LinuxFr.org : les dépêches Feed::feed_url = http://linuxfr.org/news.atom Feed::site_url = http://linuxfr.org/news -Feed::date = 1415138079 Feed::language = en-US Feed::description = Feed::logo = -Feed::items = 15 items +Feed::date = Thu, 26 Feb 15 09:33:08 +0100 Feed::isRTL() = false +Feed::items = 15 items ---- -Item::id = 38d8f48284fb03940cbb3aff9101089b81e44efb1281641bdd7c3e7e4bf3b0cd -Item::title = openSUSE 13.2 : nouvelle version du caméléon disponible ! -Item::url = http://linuxfr.org/news/opensuse-13-2-nouvelle-version-du-cameleon-disponible -Item::date = 1415122640 +Item::id = 56198c98ae852d21c369bfb5ffbc2ad13db2f3227236dde3e21ca1a9eb943faf +Item::title = Les brevets logiciels : un frein à l'innovation et la recherche (un nouvel exemple aux États-Unis) +Item::url = http://linuxfr.org/news/les-brevets-logiciels-un-frein-a-l-innovation-et-la-recherche-un-nouvel-exemple-aux-etats-unis Item::language = en-US -Item::author = Syvolc +Item::author = alenvers Item::enclosure_url = Item::enclosure_type = +Item::date = Thu, 26 Feb 15 09:33:08 +0100 Item::isRTL() = false -Item::content = 18307 bytes +Item::content = 6452 bytes .... ``` @@ -186,7 +186,7 @@ $feed->getId(); // Unique feed id $feed->getTitle(); // Feed title $feed->getFeedUrl(); // Feed url $feed->getSiteUrl(); // Website url -$feed->getDate(); // Feed last updated date +$feed->getDate(); // Feed last updated date (DateTime object) $feed->getLanguage(); // Feed language $feed->getDescription(); // Feed description $feed->getLogo(); // Feed logo (can be a large image, different from icon) @@ -196,7 +196,7 @@ $feed->getItems(); // List of item objects $feed->items[0]->getId(); // Item unique id (hash) $feed->items[0]->getTitle(); // Item title $feed->items[0]->getUrl(); // Item url -$feed->items[0]->getDate(); // Item published date (timestamp) +$feed->items[0]->getDate(); // Item published date (DateTime object) $feed->items[0]->getLanguage(); // Item language $feed->items[0]->getAuthor(); // Item author $feed->items[0]->getEnclosureUrl(); // Enclosure url diff --git a/vendor/fguillot/picofeed/docs/installation.markdown b/vendor/fguillot/picofeed/docs/installation.markdown index f132b32..9bf1450 100644 --- a/vendor/fguillot/picofeed/docs/installation.markdown +++ b/vendor/fguillot/picofeed/docs/installation.markdown @@ -6,7 +6,8 @@ Versions - Development version: master - Available versions: - - v0.1.1 (stable) + - v0.1.2 (stable) + - v0.1.1 - v0.1.0 - v0.0.2 - v0.0.1 @@ -21,7 +22,7 @@ Configure your `composer.json`: ```json { "require": { - "fguillot/picofeed": "0.1.1" + "fguillot/picofeed": "0.1.2" } } ``` @@ -29,7 +30,7 @@ Configure your `composer.json`: Or simply: ```bash -composer require fguillot/picofeed:0.1.1 +composer require fguillot/picofeed:0.1.2 ``` And download the code: diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php index 5e5514f..278eeb4 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php @@ -143,7 +143,6 @@ class Curl extends Client { $headers = array( 'Connection: close', - 'User-Agent: '.$this->user_agent, ); if ($this->etag) { @@ -236,13 +235,23 @@ class Curl extends Client curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout); + curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->prepareHeaders()); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, ini_get('open_basedir') === ''); curl_setopt($ch, CURLOPT_MAXREDIRS, $this->max_redirects); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_COOKIEJAR, 'php://memory'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'php://memory'); - curl_setopt($ch, CURLOPT_SSLVERSION, 1); // Enforce TLS v1 + + // Disable SSLv3 by enforcing TLSv1.x for curl >= 7.34.0 and < 7.39.0. + // Versions prior to 7.34 and at least when compiled against openssl + // interpret this parameter as "limit to TLSv1.0" which fails for sites + // which enforce TLS 1.1+. + // Starting with curl 7.39.0 SSLv3 is disabled by default. + $version = curl_version(); + if ($version['version_number'] >= 467456 && $version['version_number'] < 468736) { + curl_setopt($ch, CURLOPT_SSLVERSION, 1); + } $ch = $this->prepareDownloadMode($ch); $ch = $this->prepareProxyContext($ch); diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Grabber.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Grabber.php index 52f2f0b..fe48904 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Grabber.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Grabber.php @@ -123,8 +123,6 @@ class Grabber * @var array */ private $stripTags = array( - 'script', - 'style', 'nav', 'header', 'footer', @@ -276,11 +274,11 @@ class Grabber } if ($this->html) { + $html_encoding = XmlParser::getEncodingFromMetaTag($this->html); - Logger::setMessage(get_called_class().': Fix encoding'); - Logger::setMessage(get_called_class().': HTTP Encoding "'.$this->encoding.'"'); - - $this->html = Encoding::convert($this->html, $this->encoding); + // Encode everything in UTF-8 + Logger::setMessage(get_called_class().': HTTP Encoding "'.$this->encoding.'" ; HTML Encoding "'.$html_encoding.'"'); + $this->html = Encoding::convert($this->html, $html_encoding ?: $this->encoding); $this->html = Filter::stripHeadTags($this->html); Logger::setMessage(get_called_class().': Content length: '.strlen($this->html).' bytes'); diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Encoding/Encoding.php b/vendor/fguillot/picofeed/lib/PicoFeed/Encoding/Encoding.php index 0ef80ad..0590c47 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Encoding/Encoding.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Encoding/Encoding.php @@ -2,6 +2,11 @@ namespace PicoFeed\Encoding; +/** + * Encoding class + * + * @package Encoding + */ class Encoding { public static function convert($input, $encoding) diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php index 83e783b..e8012dd 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Attribute.php @@ -2,7 +2,7 @@ namespace PicoFeed\Filter; -use \PicoFeed\Client\Url; +use PicoFeed\Client\Url; /** * Attribute Filter class @@ -233,6 +233,7 @@ class Attribute 'filterBlacklistResourceAttribute', 'filterProtocolUrlAttribute', 'rewriteImageProxyUrl', + 'secureIframeSrc', ); /** @@ -383,6 +384,25 @@ class Attribute return true; } + /** + * Turns iframes' src attribute from http to https to prevent + * mixed active content + * + * @access public + * @param string $tag Tag name + * @param array $attribute Atttributes name + * @param string $value Attribute value + * @return boolean + */ + public function secureIframeSrc($tag, $attribute, &$value) + { + if ($tag === 'iframe' && $attribute === 'src' && strpos($value, 'http://') === 0) { + $value = substr_replace($value, 's', 4, 0); + } + + return true; + } + /** * Rewrite image url to use with a proxy * diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Html.php b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Html.php index 86c59a4..4e04660 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Html.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Html.php @@ -2,8 +2,8 @@ namespace PicoFeed\Filter; -use \PicoFeed\Client\Url; -use \PicoFeed\Parser\XmlParser; +use PicoFeed\Client\Url; +use PicoFeed\Parser\XmlParser; /** * HTML Filter class @@ -121,6 +121,8 @@ class Html */ public function execute() { + $this->preFilter(); + $parser = xml_parser_create(); xml_set_object($parser, $this); @@ -135,6 +137,16 @@ class Html return $this->output; } + /** + * Called before XML parsing + * + * @access public + */ + public function preFilter() + { + $this->input = $this->tag->removeBlacklistedTags($this->input); + } + /** * Called after XML parsing * diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php index 40f7c6c..aa7efe4 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Filter/Tag.php @@ -2,6 +2,9 @@ namespace PicoFeed\Filter; +use DOMXpath; +use PicoFeed\Parser\XmlParser; + /** * Tag Filter class * @@ -10,6 +13,17 @@ namespace PicoFeed\Filter; */ class Tag { + /** + * Tags blacklist (Xpath expressions) + * + * @access private + * @var array + */ + private $tag_blacklist = array( + '//script', + '//style', + ); + /** * Tags whitelist * @@ -104,7 +118,7 @@ class Tag */ public function isSelfClosingTag($tag) { - return in_array($tag, array('br', 'img')); + return $tag === 'br' || $tag === 'img'; } /** @@ -134,6 +148,33 @@ class Tag $attributes['height'] == 1 && $attributes['width'] == 1; } + /** + * Remove script tags + * + * @access public + * @param string $data Input data + * @return string + */ + public function removeBlacklistedTags($data) + { + $dom = XmlParser::getDomDocument($data); + + if ($dom === false) { + return ''; + } + + $xpath = new DOMXpath($dom); + + $nodes = $xpath->query(implode(' | ', $this->tag_blacklist)); + + foreach ($nodes as $node) { + $node->parentNode->removeChild($node); + } + + return $dom->saveXML(); + } + + /** * Remove empty tags * diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php index 9f2f108..2156652 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Atom.php @@ -131,7 +131,7 @@ class Atom extends Parser */ public function findFeedDate(SimpleXMLElement $xml, Feed $feed) { - $feed->date = $this->date->getTimestamp((string) $xml->updated); + $feed->date = $this->date->getDateTime((string) $xml->updated); } /** @@ -143,10 +143,15 @@ class Atom extends Parser */ public function findItemDate(SimpleXMLElement $entry, Item $item) { - $published = isset($entry->published) ? $this->date->getTimestamp((string) $entry->published) : 0; - $updated = isset($entry->updated) ? $this->date->getTimestamp((string) $entry->updated) : 0; + $published = isset($entry->published) ? $this->date->getDateTime((string) $entry->published) : null; + $updated = isset($entry->updated) ? $this->date->getDateTime((string) $entry->updated) : null; - $item->date = max($published, $updated) ?: time(); + if ($published !== null && $updated !== null) { + $item->date = max($published, $updated); + } + else { + $item->date = $updated ?: $published; + } } /** diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/DateParser.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/DateParser.php index 89f189e..92d0012 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/DateParser.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/DateParser.php @@ -21,7 +21,7 @@ class DateParser */ public $timezone = 'UTC'; - /** + /** * Supported formats [ 'format' => length ] * * @access public @@ -60,9 +60,9 @@ class DateParser * * @access public * @param string $value Original date format - * @return integer Timestamp + * @return DateTime */ - public function getTimestamp($value) + public function getDateTime($value) { $value = trim($value); @@ -73,14 +73,13 @@ class DateParser $truncated_value = substr($truncated_value, 0, $length); } - $timestamp = $this->getValidDate($format, $truncated_value); - if ($timestamp > 0) { - return $timestamp; + $date = $this->getValidDate($format, $truncated_value); + if ($date !== false) { + return $date; } } - $date = new DateTime('now', new DateTimeZone($this->timezone)); - return $date->getTimestamp(); + return $this->getCurrentDateTime(); } /** @@ -89,7 +88,7 @@ class DateParser * @access public * @param string $format Date format * @param string $value Original date value - * @return integer Timestamp + * @return DateTime */ public function getValidDate($format, $value) { @@ -100,10 +99,21 @@ class DateParser $errors = DateTime::getLastErrors(); if ($errors['error_count'] === 0 && $errors['warning_count'] === 0) { - return $date->getTimestamp(); + return $date; } } - return 0; + return false; + } + + /** + * Get the current datetime + * + * @access public + * @return DateTime + */ + public function getCurrentDateTime() + { + return new DateTime('now', new DateTimeZone($this->timezone)); } } diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php index 74e9ab4..93831e7 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Feed.php @@ -62,9 +62,9 @@ class Feed * Feed date * * @access public - * @var integer + * @var \DateTime */ - public $date = 0; + public $date = null; /** * Feed language @@ -100,10 +100,11 @@ class Feed { $output = ''; - foreach (array('id', 'title', 'feed_url', 'site_url', 'date', 'language', 'description', 'logo') as $property) { + foreach (array('id', 'title', 'feed_url', 'site_url', 'language', 'description', 'logo') as $property) { $output .= 'Feed::'.$property.' = '.$this->$property.PHP_EOL; } + $output .= 'Feed::date = '.$this->date->format(DATE_RFC822).PHP_EOL; $output .= 'Feed::isRTL() = '.($this->isRTL() ? 'true' : 'false').PHP_EOL; $output .= 'Feed::items = '.count($this->items).' items'.PHP_EOL; diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php index 3642ccc..1585131 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Item.php @@ -63,9 +63,9 @@ class Item * Item date * * @access public - * @var integer + * @var \DateTime */ - public $date = 0; + public $date = null; /** * Item content @@ -109,10 +109,11 @@ class Item { $output = ''; - foreach (array('id', 'title', 'url', 'date', 'language', 'author', 'enclosure_url', 'enclosure_type') as $property) { + foreach (array('id', 'title', 'url', 'language', 'author', 'enclosure_url', 'enclosure_type') as $property) { $output .= 'Item::'.$property.' = '.$this->$property.PHP_EOL; } + $output .= 'Item::date = '.$this->date->format(DATE_RFC822).PHP_EOL; $output .= 'Item::isRTL() = '.($this->isRTL() ? 'true' : 'false').PHP_EOL; $output .= 'Item::content = '.strlen($this->content).' bytes'.PHP_EOL; diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss10.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss10.php index da57327..16c66a0 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss10.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss10.php @@ -33,7 +33,7 @@ class Rss10 extends Rss20 */ public function findFeedDate(SimpleXMLElement $xml, Feed $feed) { - $feed->date = $this->date->getTimestamp(XmlParser::getNamespaceValue($xml->channel, $this->namespaces, 'date')); + $feed->date = $this->date->getDateTime(XmlParser::getNamespaceValue($xml->channel, $this->namespaces, 'date')); } /** diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php index 114308f..b26c752 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/Rss20.php @@ -134,7 +134,7 @@ class Rss20 extends Parser public function findFeedDate(SimpleXMLElement $xml, Feed $feed) { $date = isset($xml->channel->pubDate) ? $xml->channel->pubDate : $xml->channel->lastBuildDate; - $feed->date = $this->date->getTimestamp((string) $date); + $feed->date = $this->date->getDateTime((string) $date); } /** @@ -156,7 +156,7 @@ class Rss20 extends Parser $date = (string) $entry->pubDate; } - $item->date = $this->date->getTimestamp($date); + $item->date = $this->date->getDateTime($date); } /** @@ -208,7 +208,7 @@ class Rss20 extends Parser { $content = XmlParser::getNamespaceValue($entry, $this->namespaces, 'encoded'); - if (empty($content) && $entry->description->count() > 0) { + if (trim($content) === '' && $entry->description->count() > 0) { $content = (string) $entry->description; } diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php index 73a4a43..2c68c50 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Parser/XmlParser.php @@ -90,10 +90,14 @@ class XmlParser * @static * @access public * @param string $input XML content - * @return \DOMNode + * @return \DOMNDocument */ public static function getDomDocument($input) { + if (empty($input)) { + return false; + } + $dom = self::scanInput($input, function ($in) { $dom = new DomDocument; $dom->loadXml($in, LIBXML_NONET); @@ -207,6 +211,49 @@ class XmlParser return $encoding; } + /** + * Extract charset from meta tag + * + * @static + * @access public + * @param string $data meta tag content + * @return string + */ + public static function findCharset($data) + { + $result = explode('charset=', $data); + return isset($result[1]) ? $result[1] : $data; + } + + /** + * Get the encoding from a xml tag + * + * @static + * @access public + * @param string $data Input data + * @return string + */ + public static function getEncodingFromMetaTag($data) + { + $encoding = ''; + + $dom = static::getHtmlDocument($data); + $xpath = new DOMXPath($dom); + + $tags = array( + '/html/head/meta[translate(@http-equiv, "CENOPTY", "cenopty")="content-type"]/@content', //HTML4, convert upper to lower-case + '/html/head/meta/@charset', //HTML5 + ); + + $nodes = $xpath->query(implode(' | ', $tags)); + + foreach ($nodes as $node) { + $encoding = static::findCharset($node->nodeValue); + } + + return $encoding; + } + /** * Get xml:lang value * diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.wired.com.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.wired.com.php index 6e25f2c..32c0475 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.wired.com.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.wired.com.php @@ -5,8 +5,6 @@ return array( '//div[@class="entry"]', ), 'strip' => array( - '//script', - '//style', '//*[@id="linker_widget"]', '//*[contains(@class, "bio")]', '//*[contains(@class, "entry-footer")]', diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/01net.com.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/01net.com.php index 85c0e7e..615ad77 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/01net.com.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/01net.com.php @@ -5,7 +5,6 @@ return array( '//div[@class="article_ventre_box"]', ), 'strip' => array( - '//script', '//link', '//*[contains(@class, "article_navigation")]', '//h1', diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/journaldugeek.com.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/journaldugeek.com.php index 72de691..ad0d67a 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/journaldugeek.com.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/journaldugeek.com.php @@ -3,8 +3,5 @@ return array( 'test_url' => 'http://www./2014/05/20/le-playstation-now-arrive-en-beta-fermee-aux-etats-unis/', 'body' => array( '//div[@class="post-content"]', - ), - 'strip' => array( - '//style' ) ); \ No newline at end of file diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/lejapon.fr.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/lejapon.fr.php index 8066c3d..fbc2e53 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/lejapon.fr.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/lejapon.fr.php @@ -5,7 +5,6 @@ return array( '//div[@class="entry"]' ), 'strip' => array( - '//script', '//*[contains(@class, "addthis_toolbox")]', '//*[contains(@class, "addthis_default_style")]', '//*[@class="navigation small"]', diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/smallhousebliss.com.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/smallhousebliss.com.php index 395cadd..8bea4fb 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/smallhousebliss.com.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/smallhousebliss.com.php @@ -5,8 +5,6 @@ return array( '//div[@class="post-content"]', ), 'strip' => array( - '//style', - '//script', '//*[contains(@class, "gallery")]', '//*[contains(@class, "share")]', '//*[contains(@class, "wpcnt")]', diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/spiegel.de.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/spiegel.de.php index 3fb2316..375b17c 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/spiegel.de.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/spiegel.de.php @@ -2,6 +2,6 @@ return array( 'test_url' => 'http://www.spiegel.de/politik/ausland/afrika-angola-geht-gegen-islam-vor-und-schliesst-moscheen-a-935788.html', 'body' => array( - '//h2[contains(@class, "article-section")]' + '//div[contains(@class, "article-section")]' ) ); \ No newline at end of file diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/techcrunch.com.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/techcrunch.com.php index 7f1a870..bc4d5b8 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/techcrunch.com.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/techcrunch.com.php @@ -6,8 +6,6 @@ return array( '//div[@class="body-copy"]', ), 'strip' => array( - '//script', - '//style', '//*[contains(@class, "module-crunchbase")]' ) ); diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/undeadly.org.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/undeadly.org.php index 1a74304..f36ccfe 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/undeadly.org.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/undeadly.org.php @@ -5,7 +5,6 @@ return array( '/html/body/table[3]/tbody/tr/td[1]/table[2]/tr/td[1]' ), 'strip' => array( - '//style', '//font', ), ); \ No newline at end of file diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.bbc.co.uk.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.bbc.co.uk.php index 3dfa2ea..5440781 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.bbc.co.uk.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.bbc.co.uk.php @@ -6,9 +6,7 @@ return array( '//div[@class="indPost"]' ), 'strip' => array( - '//script', '//form', - '//style', '//*[@class="warning"]', '//*[@class="story-date"]', '//*[@class="story-header"]', diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.cnn.com.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.cnn.com.php index 472832f..5ceb3bd 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.cnn.com.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.cnn.com.php @@ -5,8 +5,6 @@ return array( '//div[@class="cnn_strycntntlft"]', ), 'strip' => array( - '//script', - '//style', '//div[@class="cnn_stryshrwdgtbtm"]', '//div[@class="cnn_strybtmcntnt"]', '//div[@class="cnn_strylftcntnt"]', diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.lepoint.fr.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.lepoint.fr.php index 27b80e7..adb5749 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.lepoint.fr.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.lepoint.fr.php @@ -5,8 +5,6 @@ return array( '//article', ), 'strip' => array( - '//script', - '//style', '//*[contains(@class, "info_article")]', '//*[contains(@class, "fildariane_titre")]', '//*[contains(@class, "entete2_article")]', diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.npr.org.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.npr.org.php index f2bc1b6..630c060 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.npr.org.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.npr.org.php @@ -5,8 +5,6 @@ return array( '//div[@id="storytext"]', ), 'strip' => array( - '//script', - '//style', '//*[@class="bucket img"]', '//*[@class="creditwrap"]', '//*[@class="captionwrap"]', diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.slate.fr.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.slate.fr.php index d2dc500..de211f4 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.slate.fr.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/www.slate.fr.php @@ -5,8 +5,6 @@ return array( '//div[@class="article_content"]', ), 'strip' => array( - '//script', - '//style', '//*[@id="slate_associated_bn"]', '//*[@id="ligatus-article"]', '//*[@id="article_sidebar"]', diff --git a/vendor/fguillot/picofeed/tests/Client/ClientTest.php b/vendor/fguillot/picofeed/tests/Client/ClientTest.php index 8eaa346..7959281 100644 --- a/vendor/fguillot/picofeed/tests/Client/ClientTest.php +++ b/vendor/fguillot/picofeed/tests/Client/ClientTest.php @@ -18,19 +18,18 @@ class ClientTest extends PHPUnit_Framework_TestCase $this->assertNotEmpty($client->getLastModified()); } -// // disabled due to https://github.com/sebastianbergmann/phpunit/issues/1452 -// /** -// * @runInSeparateProcess -// */ -// public function testPassthrough() -// { -// $client = Client::getInstance(); -// $client->setUrl('http://miniflux.net/favicon.ico'); -// $client->enablePassthroughMode(); -// $client->execute(); -// -// $this->expectOutputString('no_to_be_defined'); -// } + /** + * @runInSeparateProcess + */ + public function testPassthrough() + { + $client = Client::getInstance(); + $client->setUrl('http://miniflux.net/favicon.ico'); + $client->enablePassthroughMode(); + $client->execute(); + + $this->expectOutputString(file_get_contents('tests/fixtures/miniflux_favicon.ico')); + } public function testCacheBothHaveToMatch() { diff --git a/vendor/fguillot/picofeed/tests/Client/CurlTest.php b/vendor/fguillot/picofeed/tests/Client/CurlTest.php index 0ade6d2..e141a1f 100644 --- a/vendor/fguillot/picofeed/tests/Client/CurlTest.php +++ b/vendor/fguillot/picofeed/tests/Client/CurlTest.php @@ -18,19 +18,18 @@ class CurlTest extends PHPUnit_Framework_TestCase $this->assertEquals('text/html; charset=utf-8', $result['headers']['Content-Type']); } -// // disabled due to https://github.com/sebastianbergmann/phpunit/issues/1452 -// /** -// * @runInSeparateProcess -// */ -// public function testPassthrough() -// { -// $client = new Curl; -// $client->setUrl('http://miniflux.net/favicon.ico'); -// $client->enablePassthroughMode(); -// $client->doRequest(); -// -// $this->expectOutputString('no_to_be_defined'); -// } + /** + * @runInSeparateProcess + */ + public function testPassthrough() + { + $client = new Curl; + $client->setUrl('http://miniflux.net/favicon.ico'); + $client->enablePassthroughMode(); + $client->doRequest(); + + $this->expectOutputString(file_get_contents('tests/fixtures/miniflux_favicon.ico')); + } public function testRedirect() { diff --git a/vendor/fguillot/picofeed/tests/Client/StreamTest.php b/vendor/fguillot/picofeed/tests/Client/StreamTest.php index 83a5a20..314d488 100644 --- a/vendor/fguillot/picofeed/tests/Client/StreamTest.php +++ b/vendor/fguillot/picofeed/tests/Client/StreamTest.php @@ -27,19 +27,18 @@ class StreamTest extends PHPUnit_Framework_TestCase $this->assertEquals('', substr(trim($result['body']), -7)); } -// // disabled due to https://github.com/sebastianbergmann/phpunit/issues/1452 -// /** -// * @runInSeparateProcess -// */ -// public function testPassthrough() -// { -// $client = new Stream; -// $client->setUrl('http://miniflux.net/favicon.ico'); -// $client->enablePassthroughMode(); -// $client->doRequest(); -// -// $this->expectOutputString('no_to_be_defined'); -// } + /** + * @runInSeparateProcess + */ + public function testPassthrough() + { + $client = new Stream; + $client->setUrl('http://miniflux.net/favicon.ico'); + $client->enablePassthroughMode(); + $client->doRequest(); + + $this->expectOutputString(file_get_contents('tests/fixtures/miniflux_favicon.ico')); + } public function testRedirect() { diff --git a/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php b/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php index 907aaa2..bf7dd22 100644 --- a/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php +++ b/vendor/fguillot/picofeed/tests/Filter/AttributeFilterTest.php @@ -39,8 +39,8 @@ class AttributeFilterTest extends PHPUnit_Framework_TestCase $this->assertTrue($filter->filterIntegerAttribute('iframe', 'width', '450')); $this->assertFalse($filter->filterIntegerAttribute('iframe', 'width', 'test')); - $this->assertEquals(array('width' => '10', 'src' => 'http://www.youtube.com/test'), $filter->filter('iframe', array('width' => '10', 'src' => 'http://www.youtube.com/test'))); - $this->assertEquals(array('src' => 'http://www.youtube.com/test'), $filter->filter('iframe', array('width' => 'test', 'src' => 'http://www.youtube.com/test'))); + $this->assertEquals(array('width' => '10', 'src' => 'https://www.youtube.com/test'), $filter->filter('iframe', array('width' => '10', 'src' => 'http://www.youtube.com/test'))); + $this->assertEquals(array('src' => 'https://www.youtube.com/test'), $filter->filter('iframe', array('width' => 'test', 'src' => 'http://www.youtube.com/test'))); } public function testRewriteProxyImageUrl() @@ -125,7 +125,7 @@ class AttributeFilterTest extends PHPUnit_Framework_TestCase $this->assertFalse($filter->filterIframeAttribute('iframe', 'src', '//www.youtube.com/test')); $this->assertFalse($filter->filterIframeAttribute('iframe', 'src', '//www.bidule.com/test')); - $this->assertEquals(array('src' => 'http://www.youtube.com/test'), $filter->filter('iframe', array('src' => '//www.youtube.com/test'))); + $this->assertEquals(array('src' => 'https://www.youtube.com/test'), $filter->filter('iframe', array('src' => '//www.youtube.com/test'))); } public function testFilterBlacklistAttribute() diff --git a/vendor/fguillot/picofeed/tests/Filter/FilterTest.php b/vendor/fguillot/picofeed/tests/Filter/FilterTest.php index d761650..f5f98a9 100644 --- a/vendor/fguillot/picofeed/tests/Filter/FilterTest.php +++ b/vendor/fguillot/picofeed/tests/Filter/FilterTest.php @@ -71,10 +71,11 @@ class FilterTest extends PHPUnit_Framework_TestCase public function testOverrideFilters() { $data = ''; + $expected = ''; $f = Filter::html($data, 'http://blabla'); $f->attribute->setIframeWhitelist(array('http://www.kickstarter.com')); - $this->assertEquals($data, $f->execute()); + $this->assertEquals($expected, $f->execute()); $data = ''; diff --git a/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php b/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php index 2711674..03aeb33 100644 --- a/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php +++ b/vendor/fguillot/picofeed/tests/Filter/HtmlFilterTest.php @@ -1,11 +1,17 @@ assertEquals('', $filter->execute()); + } + public function testExecute() { $html = ' @@ -25,9 +31,28 @@ class HtmlFilterTest extends PHPUnit_Framework_TestCase $this->assertEmpty($f->execute()); $data = ''; + $expected = ''; $f = new Html($data, 'http://blabla'); - $this->assertEquals($data, $f->execute()); + $this->assertEquals($expected, $f->execute()); + } + + public function testClearScriptAttributes() + { + $data = '

something

hi

'; + + $f = new Html($data, 'http://blabla'); + $expected = '

something

hi

'; + $this->assertEquals($expected, $f->execute()); + } + + public function testClearStyleAttributes() + { + $data = '

something

hi

'; + + $f = new Html($data, 'http://blabla'); + $expected = '

something

hi

'; + $this->assertEquals($expected, $f->execute()); } public function testEmptyTags() @@ -50,7 +75,7 @@ EOD; $data = ''; $f = new Html($data, 'http://blabla'); - $this->assertEquals('', $f->execute()); + $this->assertEquals('', $f->execute()); } public function testRelativeScheme() @@ -123,46 +148,4 @@ x-amz-id-2: DDjqfqz2ZJufzqRAcj1mh+9XvSogrPohKHwXlo8IlkzH67G6w4wnjn9HYgbs4uI0 $f = new Html('
', 'http://blabla'); $this->assertEquals('', $f->execute()); } -/* - public function testFilter() - { - $input = <<
-
- Flaque de pluie -
La Saussaye, France, 6 août 2014
-
- -
-
-

Spring had truly arrived. Countless streams suddenly materialized all over the roads, fields, grasslands, and thickets; flowing as if the melting snow's waters were spilling over.

-
-

Takiji Kobayashi, Yasuko.

-
- -

La pluie abonde. La forêt humide resplendit. L'eau monte, l'eau déborde. Il reste pourtant notre humanité. Toute entière, resplendissante.

- -
- -EOD; - - $expected = << - Flaque de pluie -
La Saussaye, France, 6 août 2014
- - - -
-

Spring had truly arrived. Countless streams suddenly materialized all over the roads, fields, grasslands, and thickets; flowing as if the melting snow's waters were spilling over.

-
-

Takiji Kobayashi, Yasuko.

- - -

La pluie abonde. La forêt humide resplendit. L'eau monte, l'eau déborde. Il reste pourtant notre humanité. Toute entière, resplendissante.

-EOD; - - $f = new Html($input, 'http://www.la-grange.net/'); - $this->assertEquals($expected, $f->execute()); - }*/ } diff --git a/vendor/fguillot/picofeed/tests/Parser/AtomParserTest.php b/vendor/fguillot/picofeed/tests/Parser/AtomParserTest.php index 04882c5..9246948 100644 --- a/vendor/fguillot/picofeed/tests/Parser/AtomParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/AtomParserTest.php @@ -119,11 +119,11 @@ class AtomParserTest extends PHPUnit_Framework_TestCase { $parser = new Atom(file_get_contents('tests/fixtures/atom.xml')); $feed = $parser->execute(); - $this->assertEquals(1360148333, $feed->getDate()); + $this->assertEquals(1360148333, $feed->getDate()->getTimestamp(), '', 1); $parser = new Atom(file_get_contents('tests/fixtures/atomsample.xml')); $feed = $parser->execute(); - $this->assertEquals(1071340202, $feed->getDate()); + $this->assertEquals(1071340202, $feed->getDate()->getTimestamp(), '', 1); } public function testFeedLanguage() @@ -196,17 +196,17 @@ class AtomParserTest extends PHPUnit_Framework_TestCase $parser = new Atom(file_get_contents('tests/fixtures/atom.xml')); $feed = $parser->execute(); $this->assertNotEmpty($feed->items); - $this->assertEquals(1360011661, $feed->items[1]->getDate()); + $this->assertEquals(1360011661, $feed->items[1]->getDate()->getTimestamp(), '', 1); $parser = new Atom(file_get_contents('tests/fixtures/atomsample.xml')); $feed = $parser->execute(); $this->assertNotEmpty($feed->items); - $this->assertEquals(1071340202, $feed->items[0]->getDate()); + $this->assertEquals(1071340202, $feed->items[0]->getDate()->getTimestamp(), '', 1); $parser = new Atom(file_get_contents('tests/fixtures/youtube.xml')); $feed = $parser->execute(); $this->assertNotEmpty($feed->items); - $this->assertEquals(1336825342, $feed->items[1]->getDate()); // Should return the published date + $this->assertEquals(1336825342, $feed->items[1]->getDate()->getTimestamp(), '', 1); // Should return the published date } public function testItemLanguage() diff --git a/vendor/fguillot/picofeed/tests/Parser/DateParserTest.php b/vendor/fguillot/picofeed/tests/Parser/DateParserTest.php index 6ad464b..ab35d0b 100644 --- a/vendor/fguillot/picofeed/tests/Parser/DateParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/DateParserTest.php @@ -12,37 +12,37 @@ class DateParserTest extends PHPUnit_Framework_TestCase date_default_timezone_set('UTC'); - $this->assertEquals(1359066183, $parser->getTimestamp('Thu, 24 Jan 2013 22:23:03 +0000')); - $this->assertEquals(1362992761, $parser->getTimestamp('2013-03-11T09:06:01+00:00')); - $this->assertEquals(1363752990, $parser->getTimestamp('2013-03-20T04:16:30+00:00')); - $this->assertEquals(1359066183, $parser->getTimestamp('Thu, 24 Jan 2013 22:23:03 +0000')); - $this->assertEquals(1380929699, $parser->getTimestamp('Sat, 04 Oct 2013 02:34:59 +0300')); - $this->assertEquals(1054633161, $parser->getTimestamp('Tue, 03 Jun 2003 09:39:21 GMT')); - $this->assertEquals(1071340202, $parser->getTimestamp('2003-12-13T18:30:02Z')); - $this->assertEquals(1364234797, $parser->getTimestamp('Mon, 25 Mar 2013 19:06:37 +0100')); - $this->assertEquals(1360054941, $parser->getTimestamp('2013-02-05T09:02:21.880-08:00')); - $this->assertEquals(1286834400, $parser->getTimestamp('Tue, 12 Oct 2010 00:00:00 IST')); - $this->assertEquals('2014-12-15 19:49', date('Y-m-d H:i', $parser->getTimestamp('15 Dec 2014 19:49:07 +0100'))); - $this->assertEquals('2012-05-15', date('Y-m-d', $parser->getTimestamp('Tue, 15 May 2012 24:05:00 UTC'))); - $this->assertEquals('2013-09-12', date('Y-m-d', $parser->getTimestamp('Thu, 12 Sep 2013 7:00:00 UTC'))); - $this->assertEquals('2012-01-31', date('Y-m-d', $parser->getTimestamp('01.31.2012'))); - $this->assertEquals('2012-01-31', date('Y-m-d', $parser->getTimestamp('01/31/2012'))); - $this->assertEquals('2012-01-31', date('Y-m-d', $parser->getTimestamp('2012-01-31'))); - $this->assertEquals('2010-02-24', date('Y-m-d', $parser->getTimestamp('2010-02-245T15:27:52Z'))); - $this->assertEquals('2010-08-20', date('Y-m-d', $parser->getTimestamp('2010-08-20Thh:08:ssZ'))); - $this->assertEquals(1288648057, $parser->getTimestamp('Mon, 01 Nov 2010 21:47:37 UT')); - $this->assertEquals(1346069615, $parser->getTimestamp('Mon Aug 27 2012 12:13:35 GMT-0700 (PDT)')); - $this->assertEquals(time(), $parser->getTimestamp('Tue, 3 Febuary 2010 00:00:00 IST'), '', 1); - $this->assertEquals(time(), $parser->getTimestamp('############# EST'), '', 1); - $this->assertEquals(time(), $parser->getTimestamp('Wed, 30 Nov -0001 00:00:00 +0000'), '', 1); - $this->assertEquals(time(), $parser->getTimestamp('čet, 24 maj 2012 00:00:00'), '', 1); - $this->assertEquals(time(), $parser->getTimestamp('-0-0T::Z'), '', 1); - $this->assertEquals(time(), $parser->getTimestamp('Wed, 18 2012'), '', 1); - $this->assertEquals(time(), $parser->getTimestamp("'2009-09-30 CDT16:09:54"), '', 1); - $this->assertEquals(time(), $parser->getTimestamp('ary 8 Jan 2013 00:00:00 GMT'), '', 1); - $this->assertEquals(time(), $parser->getTimestamp('Sat, 11 00:00:01 GMT'), '', 1); - $this->assertEquals(1370631743, $parser->getTimestamp('Fri Jun 07 2013 19:02:23 GMT+0000 (UTC)')); - $this->assertEquals(1377412225, $parser->getTimestamp('25/08/2013 06:30:25 م')); - $this->assertEquals(time(), $parser->getTimestamp('+0400'), '', 1); + $this->assertEquals(1359066183, $parser->getDateTime('Thu, 24 Jan 2013 22:23:03 +0000')->getTimestamp(), '', 1); + $this->assertEquals(1362992761, $parser->getDateTime('2013-03-11T09:06:01+00:00')->getTimestamp(), '', 1); + $this->assertEquals(1363752990, $parser->getDateTime('2013-03-20T04:16:30+00:00')->getTimestamp(), '', 1); + $this->assertEquals(1359066183, $parser->getDateTime('Thu, 24 Jan 2013 22:23:03 +0000')->getTimestamp(), '', 1); + $this->assertEquals(1380929699, $parser->getDateTime('Sat, 04 Oct 2013 02:34:59 +0300')->getTimestamp(), '', 1); + $this->assertEquals(1054633161, $parser->getDateTime('Tue, 03 Jun 2003 09:39:21 GMT')->getTimestamp(), '', 1); + $this->assertEquals(1071340202, $parser->getDateTime('2003-12-13T18:30:02Z')->getTimestamp(), '', 1); + $this->assertEquals(1364234797, $parser->getDateTime('Mon, 25 Mar 2013 19:06:37 +0100')->getTimestamp(), '', 1); + $this->assertEquals(1360054941, $parser->getDateTime('2013-02-05T09:02:21.880-08:00')->getTimestamp(), '', 1); + $this->assertEquals(1286834400, $parser->getDateTime('Tue, 12 Oct 2010 00:00:00 IST')->getTimestamp(), '', 1); + $this->assertEquals('2014-12-15 19:49', $parser->getDateTime('15 Dec 2014 19:49:07 +0100')->format('Y-m-d H:i')); + $this->assertEquals('2012-05-15', $parser->getDateTime('Tue, 15 May 2012 24:05:00 UTC')->format('Y-m-d')); + $this->assertEquals('2013-09-12', $parser->getDateTime('Thu, 12 Sep 2013 7:00:00 UTC')->format('Y-m-d')); + $this->assertEquals('2012-01-31', $parser->getDateTime('01.31.2012')->format('Y-m-d')); + $this->assertEquals('2012-01-31', $parser->getDateTime('01/31/2012')->format('Y-m-d')); + $this->assertEquals('2012-01-31', $parser->getDateTime('2012-01-31')->format('Y-m-d')); + $this->assertEquals('2010-02-24', $parser->getDateTime('2010-02-245T15:27:52Z')->format('Y-m-d')); + $this->assertEquals('2010-08-20', $parser->getDateTime('2010-08-20Thh:08:ssZ')->format('Y-m-d')); + $this->assertEquals(1288648057, $parser->getDateTime('Mon, 01 Nov 2010 21:47:37 UT')->getTimestamp(), '', 1); + $this->assertEquals(1346069615, $parser->getDateTime('Mon Aug 27 2012 12:13:35 GMT-0700 (PDT)')->getTimestamp(), '', 1); + $this->assertEquals($parser->getCurrentDateTime(), $parser->getDateTime('Tue, 3 Febuary 2010 00:00:00 IST')); + $this->assertEquals($parser->getCurrentDateTime(), $parser->getDateTime('############# EST')); + $this->assertEquals($parser->getCurrentDateTime(), $parser->getDateTime('Wed, 30 Nov -0001 00:00:00 +0000')); + $this->assertEquals($parser->getCurrentDateTime(), $parser->getDateTime('čet, 24 maj 2012 00:00:00')); + $this->assertEquals($parser->getCurrentDateTime(), $parser->getDateTime('-0-0T::Z')); + $this->assertEquals($parser->getCurrentDateTime(), $parser->getDateTime('Wed, 18 2012')); + $this->assertEquals($parser->getCurrentDateTime(), $parser->getDateTime("'2009-09-30 CDT16:09:54")); + $this->assertEquals($parser->getCurrentDateTime(), $parser->getDateTime('ary 8 Jan 2013 00:00:00 GMT')); + $this->assertEquals($parser->getCurrentDateTime(), $parser->getDateTime('Sat, 11 00:00:01 GMT')); + $this->assertEquals(1370631743, $parser->getDateTime('Fri Jun 07 2013 19:02:23 GMT+0000 (UTC)')->getTimestamp(), '', 1); + $this->assertEquals(1377412225, $parser->getDateTime('25/08/2013 06:30:25 م')->getTimestamp(), '', 1); + $this->assertEquals($parser->getCurrentDateTime(), $parser->getDateTime('+0400')); } } diff --git a/vendor/fguillot/picofeed/tests/Parser/Rss10ParserTest.php b/vendor/fguillot/picofeed/tests/Parser/Rss10ParserTest.php index f06ff35..945eb3a 100644 --- a/vendor/fguillot/picofeed/tests/Parser/Rss10ParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/Rss10ParserTest.php @@ -47,7 +47,7 @@ class Rss10ParserTest extends PHPUnit_Framework_TestCase { $parser = new Rss10(file_get_contents('tests/fixtures/planete-jquery.xml')); $feed = $parser->execute(); - $this->assertEquals(1363752990, $feed->getDate()); + $this->assertEquals(1363752990, $feed->getDate()->getTimestamp(), '', 1); } public function testFeedLanguage() @@ -90,7 +90,7 @@ class Rss10ParserTest extends PHPUnit_Framework_TestCase $parser = new Rss10(file_get_contents('tests/fixtures/planete-jquery.xml')); $feed = $parser->execute(); $this->assertNotEmpty($feed->items); - $this->assertEquals(1362647700, $feed->items[1]->getDate()); + $this->assertEquals(1362647700, $feed->items[1]->getDate()->getTimestamp(), '', 1); } public function testItemLanguage() diff --git a/vendor/fguillot/picofeed/tests/Parser/Rss20ParserTest.php b/vendor/fguillot/picofeed/tests/Parser/Rss20ParserTest.php index 344917d..f417a40 100644 --- a/vendor/fguillot/picofeed/tests/Parser/Rss20ParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/Rss20ParserTest.php @@ -1,8 +1,9 @@ execute(); - $this->assertEquals(1359066183, $feed->getDate()); + $this->assertEquals(1359066183, $feed->getDate()->getTimestamp()); $parser = new Rss20(file_get_contents('tests/fixtures/fulltextrss.xml')); $feed = $parser->execute(); - $this->assertEquals(time(), $feed->getDate(), '', 1); + $this->assertEquals(new DateTime, $feed->getDate()); } public function testFeedLanguage() @@ -171,12 +172,12 @@ class Rss20ParserTest extends PHPUnit_Framework_TestCase $parser = new Rss20(file_get_contents('tests/fixtures/rss20.xml')); $feed = $parser->execute(); $this->assertNotEmpty($feed->items); - $this->assertEquals(1357006940, $feed->items[1]->getDate()); + $this->assertEquals(1357006940, $feed->items[1]->getDate()->getTimestamp()); $parser = new Rss20(file_get_contents('tests/fixtures/fulltextrss.xml')); $feed = $parser->execute(); $this->assertNotEmpty($feed->items); - $this->assertEquals(1365781095, $feed->items[0]->getDate()); + $this->assertEquals(1365781095, $feed->items[0]->getDate()->getTimestamp()); } public function testItemLanguage() @@ -202,6 +203,14 @@ class Rss20ParserTest extends PHPUnit_Framework_TestCase public function testItemContent() { + $parser = new Rss20(file_get_contents('tests/fixtures/allgemeine-zeitung.xml')); + $feed = $parser->execute(); + $this->assertNotEmpty($feed->items); + $this->assertEquals( + '

OBER-FLÖRSHEIM - (red). Sein erheblich beschädigtes Fahrzeug hat ein Fahrer in der Nacht von Donnerstag auf Freitag mitten auf der Ober-Flörsheimer Hauptstraße stehen lassen. Beim Verlassen des Autos in Richtung ...

', + $feed->items[2]->getContent() + ); + $parser = new Rss20(file_get_contents('tests/fixtures/rss20.xml')); $feed = $parser->execute(); $this->assertNotEmpty($feed->items); diff --git a/vendor/fguillot/picofeed/tests/Parser/Rss91ParserTest.php b/vendor/fguillot/picofeed/tests/Parser/Rss91ParserTest.php index 111f449..b05e87f 100644 --- a/vendor/fguillot/picofeed/tests/Parser/Rss91ParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/Rss91ParserTest.php @@ -18,13 +18,13 @@ class Rss91ParserTest extends PHPUnit_Framework_TestCase $this->assertEquals('', $feed->getFeedUrl()); $this->assertEquals('http://writetheweb.com/', $feed->getSiteUrl()); $this->assertEquals('http://writetheweb.com/', $feed->getId()); - $this->assertEquals(time(), $feed->getDate(), '', 1); + $this->assertEquals(time(), $feed->getDate()->getTimestamp(), '', 1); $this->assertEquals(6, count($feed->items)); $this->assertEquals('Giving the world a pluggable Gnutella', $feed->items[0]->getTitle()); $this->assertEquals('http://writetheweb.com/read.php?item=24', $feed->items[0]->getUrl()); $this->assertEquals('085a9133a75542f878fa73ee2afbb6a2350b6c4fb125e6d8ca09478c47702111', $feed->items[0]->getId()); - $this->assertEquals(time(), $feed->items[0]->getDate(), '', 1); + $this->assertEquals(time(), $feed->items[0]->getDate()->getTimestamp(), '', 1); $this->assertEquals('webmaster@writetheweb.com', $feed->items[0]->getAuthor()); $this->assertTrue(strpos($feed->items[1]->getContent(), '

After a period of dormancy') === 0); } diff --git a/vendor/fguillot/picofeed/tests/Parser/Rss92ParserTest.php b/vendor/fguillot/picofeed/tests/Parser/Rss92ParserTest.php index d5358dd..5654d62 100644 --- a/vendor/fguillot/picofeed/tests/Parser/Rss92ParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/Rss92ParserTest.php @@ -18,7 +18,7 @@ class Rss92ParserTest extends PHPUnit_Framework_TestCase $this->assertEquals('', $feed->getFeedUrl()); $this->assertEquals('http://www.universfreebox.com/', $feed->getSiteUrl()); $this->assertEquals('http://www.universfreebox.com/', $feed->getId()); - $this->assertEquals(time(), $feed->date, '', 1); + $this->assertEquals(time(), $feed->getDate()->getTimestamp(), '', 1); $this->assertEquals(30, count($feed->items)); $this->assertEquals('Retour de Xavier Niel sur Twitter, « sans initiative privée, pas de révolution #Born2code »', $feed->items[0]->title); diff --git a/vendor/fguillot/picofeed/tests/Parser/XmlParserTest.php b/vendor/fguillot/picofeed/tests/Parser/XmlParserTest.php index 87bd9da..38520eb 100644 --- a/vendor/fguillot/picofeed/tests/Parser/XmlParserTest.php +++ b/vendor/fguillot/picofeed/tests/Parser/XmlParserTest.php @@ -8,6 +8,19 @@ use PHPUnit_Framework_TestCase; class XmlParserTest extends PHPUnit_Framework_TestCase { + public function testEmpty() + { + $this->assertFalse(XmlParser::getDomDocument('')); + $this->assertFalse(XmlParser::getSimpleXml('')); + $this->assertNotFalse(XmlParser::getHtmlDocument('')); + } + + public function testGetEncodingFromMetaTag() + { + $this->assertEquals('iso-8859-1', XmlParser::getEncodingFromMetaTag('')); + $this->assertEquals('iso-8859-1', XmlParser::getEncodingFromMetaTag('')); + } + public function testGetEncodingFromXmlTag() { $this->assertEquals('utf-8', XmlParser::getEncodingFromXmlTag(" + + + + + Allgemeine Zeitung - Aktuelle Polizei-Meldungen aus der Region + Allgemeine Zeitung RSS-Feed fr die Rubrik Aktuelle Polizei-Meldungen aus der Region + http://www.allgemeine-zeitung.de + de + Sun, 01 Mar 2015 19:18:57 +0100 + + Allgemeine Zeitung + http://www.allgemeine-zeitung.de + http://www.allgemeine-zeitung.de/pics/edition/az/rss.png + + + + Bad Kreuznach: Ursache fr Brand in der ehemaligen Rose-Barracks-Kantine geklrt + http://www.allgemeine-zeitung.de/lokales/polizei/bad-kreuznach-ursache-fuer-brand-in-der-ehemaligen-rose-barracks-kantine-geklaert_15063090.htm + BAD KREUZNACH - Die Ursache fr den Brand im Gebude der ehemaligen Rose Barracks ist geklrt. Die Vermutungen zu den Ttern von Freitag haben sich besttigt. + Kirn + Sun, 01 Mar 2015 16:15:00 +0100 + http://www.allgemeine-zeitung.de/lokales/polizei/bad-kreuznach-ursache-fuer-brand-in-der-ehemaligen-rose-barracks-kantine-geklaert_15063090.htm + + ]]> + + + + Vier Verletzte bei Verkehrsunfall auf der A61 am Autobahndreieck Nahetal + http://www.allgemeine-zeitung.de/lokales/polizei/vier-verletzte-bei-verkehrsunfall-auf-der-a61-am-autobahndreieck-nahetal_15061411.htm + GENSINGEN - Bei einem Verkehrsunfall auf der A61 am Autobahndreieck Nahetal in Fahrtrichtung Koblenz sind vier Personen verletzt worden. + Kirn + Sat, 28 Feb 2015 18:28:00 +0100 + http://www.allgemeine-zeitung.de/lokales/polizei/vier-verletzte-bei-verkehrsunfall-auf-der-a61-am-autobahndreieck-nahetal_15061411.htm + + ]]> + + + + Unfallauto auf Ober-Flrsheimer Hauptstrae stehen gelassen + http://www.allgemeine-zeitung.de/lokales/polizei/unfallauto-auf-ober-floersheimer-hauptstrasse-stehen-gelassen_15058634.htm + OBER-FLRSHEIM - (red). Sein erheblich beschdigtes Fahrzeug hat ein Fahrer in der Nacht von Donnerstag auf Freitag mitten auf der Ober-Flrsheimer Hauptstrae stehen lassen. Beim Verlassen des Autos in Richtung ... + Kirn + Sat, 28 Feb 2015 01:00:00 +0100 + http://www.allgemeine-zeitung.de/lokales/polizei/unfallauto-auf-ober-floersheimer-hauptstrasse-stehen-gelassen_15058634.htm + + + + Bischofsheim: Nach Einbruch verdchtiges Prchen beobachtet + http://www.allgemeine-zeitung.de/lokales/polizei/bischofsheim-nach-einbruch-verdaechtiges-paerchen-beobachtet_15058635.htm + BISCHOFSHEIM - (red). Im Zusammenhang mit einem Einbruch in der Knigsberger Strae sind Zeugen aus der Nachbarschaft auf ein unbekanntes Prchen aufmerksam geworden. Die Kriminalpolizei in Rsselsheim ... + Kirn + Sat, 28 Feb 2015 01:00:00 +0100 + http://www.allgemeine-zeitung.de/lokales/polizei/bischofsheim-nach-einbruch-verdaechtiges-paerchen-beobachtet_15058635.htm + + + + Einbrecher erbeuten Schmuck in Niedernhausen + http://www.allgemeine-zeitung.de/lokales/polizei/einbrecher-erbeuten-schmuck-in-niedernhausen_15058636.htm + NIEDERNHAUSEN - (red). Beim Einbruch in ein Einfamilienhaus in der Breslauer Strae in Niedernhausen erbeuteten unbekannte Tter am Donnerstagvormittag einige Schmuckstcke. Die Einbrecher waren durch ein ... + Kirn + Sat, 28 Feb 2015 01:00:00 +0100 + http://www.allgemeine-zeitung.de/lokales/polizei/einbrecher-erbeuten-schmuck-in-niedernhausen_15058636.htm + + + + Zu weit links auf der B 41 + http://www.allgemeine-zeitung.de/lokales/polizei/zu-weit-links-auf-der-b-41_15058637.htm + RDESHEIM - (red). Bereits am Mittwochmorgen stie eine 21-jhrige Pkw-Fahrerin auf der Landessstrae 236 in Richtung Bundesstrae 41 mit einem zu weit links fahrenden, entgegenkommenden weien Audi, ... + Kirn + Sat, 28 Feb 2015 01:00:00 +0100 + http://www.allgemeine-zeitung.de/lokales/polizei/zu-weit-links-auf-der-b-41_15058637.htm + + + + Mann droht in Wiesbaden mit Pistole + http://www.allgemeine-zeitung.de/lokales/polizei/mann-droht-in-wiesbaden-mit-pistole_15058638.htm + WIESBADEN - (red). Die Polizei sucht nach einem Unbekannten, der am Donnerstagmittag in der Holzstrae eine Frau mit einer Pistole bedroht haben soll und dadurch einen greren Einsatz von Polizei und ... + Kirn + Sat, 28 Feb 2015 01:00:00 +0100 + http://www.allgemeine-zeitung.de/lokales/polizei/mann-droht-in-wiesbaden-mit-pistole_15058638.htm + + + + Geparktes Auto beschdigt + http://www.allgemeine-zeitung.de/lokales/polizei/geparktes-auto-beschaedigt_15058641.htm + RSSELSHEIM - (red). Im Hasengrund in Hhe des Hauses Nummer 72 ist am Donnerstag zwischen 14 und 15.30 Uhr ein Auto beschdigt worden. Der schwarze Mercedes Benz, C-Klasse, war vor dem Haus abgestellt und ... + Kirn + Sat, 28 Feb 2015 01:00:00 +0100 + http://www.allgemeine-zeitung.de/lokales/polizei/geparktes-auto-beschaedigt_15058641.htm + + + + Diebe stehlen 85 Liter Diesel + http://www.allgemeine-zeitung.de/lokales/polizei/diebe-stehlen-85-liter-diesel_15058642.htm + RSSELSHEIM - (red). Dieselkraftstoff im Wert von rund 110 Euro haben unbekannte Diebe am Donnerstagabend mitgehen lassen. DieTter hatten es in der Zeit von 20.40 Uhr bis 21.25 Uhr auf einen Lastwagen in ... + Kirn + Sat, 28 Feb 2015 01:00:00 +0100 + http://www.allgemeine-zeitung.de/lokales/polizei/diebe-stehlen-85-liter-diesel_15058642.htm + + + + Bad Kreuznach: Betrunkene Frauen am Steuer + http://www.allgemeine-zeitung.de/lokales/polizei/bad-kreuznach-betrunkene-frauen-am-steuer_15058643.htm + BAD KREUZNACH - (red). Gleich zwei Flle von Trunkenheit am Steuer registrierte die Polizei am spten Donnerstagabend. Im Rahmen einer Verkehrskontrolle wurde am Europaplatz bei einer 41-jhrigen Autofahrerin ... + Kirn + Sat, 28 Feb 2015 01:00:00 +0100 + http://www.allgemeine-zeitung.de/lokales/polizei/bad-kreuznach-betrunkene-frauen-am-steuer_15058643.htm + + + + \ No newline at end of file diff --git a/vendor/fguillot/picofeed/tests/fixtures/miniflux_favicon.ico b/vendor/fguillot/picofeed/tests/fixtures/miniflux_favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..77af6f921f6ae6c2061dab8c0ff5f8e2489861bd GIT binary patch literal 16958 zcmeI2J7`ov6o%(2f&nFs#;C*yL5z){f})^V;-j%jlR^*?(TH{yHY&T~yHc^SOQ-k% zK?@s;#mdG)M0|j<3QtxDWXF z;L-fU)?U_0*FW&@C(M=VKU`P(`47~U>}5Q<|AlKy_kWMJ(2|~i;abx3&!eUMJxk9& zJ^#@_$af08|LgZ3z5fO7t9t*N(fjZ2{2Awak39c|d|Y-L+%t9mKWxWRR42xR5&Qpe z5s%9b@3RQ*X5RnHu6SHF;yW4<<0!r@E*_T+-^UT$&CLIrD;}4P_)bN{C?D#zE*_T+ z-=`7W&CLI~D;}4P_%21nDESY#cw9DoW4^QPadBj}NG^$URo2&6;x`DyKNRu|;9FR{J?OY%JVciK*ZET`D=c%Cc&E@OhB2<~tA z&dGDw@3c3PzvT1@><9BRPTpnR&w<#SZU4J)Y|QbtP%nWRuzh{?M;S*^316f6XXDCV z^d5YUj4kW$E5E>513w$&K3|k~W`}pG`TOFZ$u_xDt;q5$DkJl+H@FT(^B^(yfwxWO zmGK@F<(#+U7qk8Y_`hgktXCx#o;BcW6M4VG<=ywQIlwO_|9fFk`JF&To>i9}DR|fb?=XFi*nE@K>2n8E15vX1=(io*0`i%289Oe9`Yu4W~F)u7%}`BQcpvqkD-PgZtHeXcQ`^~9KY#`M&aidkk%xt>%_&sbSA Y - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator; -/** - * @author Frédéric Guillot - */ abstract class Base { protected $field = ''; protected $error_message = ''; protected $data = array(); - abstract public function execute(array $data); - public function __construct($field, $error_message) { $this->field = $field; $this->error_message = $error_message; } - public function getErrorMessage() { return $this->error_message; } - public function getField() { if (is_array($this->field)) { return $this->field[0]; } + return $this->field; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validator.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validator.php index 8bb4d62..b7ae6db 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validator.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validator.php @@ -1,33 +1,19 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator; -/** - * @author Frédéric Guillot - */ class Validator { private $data = array(); private $errors = array(); private $validators = array(); - public function __construct(array $data, array $validators) { $this->data = $data; $this->validators = $validators; } - public function execute() { $result = true; @@ -48,11 +34,9 @@ class Validator return $result; } - public function addError($field, $message) { if (! isset($this->errors[$field])) { - $this->errors[$field] = array(); } @@ -64,4 +48,4 @@ class Validator { return $this->errors; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Alpha.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Alpha.php index b00b819..373b714 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Alpha.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Alpha.php @@ -1,21 +1,9 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class Alpha extends Base { public function execute(array $data) @@ -23,11 +11,10 @@ class Alpha extends Base if (isset($data[$this->field]) && $data[$this->field] !== '') { if (! ctype_alpha($data[$this->field])) { - return false; } } return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/AlphaNumeric.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/AlphaNumeric.php index e1762d6..c84716c 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/AlphaNumeric.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/AlphaNumeric.php @@ -1,21 +1,9 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class AlphaNumeric extends Base { public function execute(array $data) @@ -23,11 +11,10 @@ class AlphaNumeric extends Base if (isset($data[$this->field]) && $data[$this->field] !== '') { if (! ctype_alnum($data[$this->field])) { - return false; } } return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Date.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Date.php index 54c949b..03b4e4f 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Date.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Date.php @@ -3,7 +3,7 @@ namespace SimpleValidator\Validators; use SimpleValidator\Base; -use \DateTime; +use DateTime; class Date extends Base { diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Email.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Email.php index e4e3d5d..b6a7b63 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Email.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Email.php @@ -1,21 +1,9 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class Email extends Base { public function execute(array $data) diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Equals.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Equals.php index 91f34e4..26b8038 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Equals.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Equals.php @@ -1,21 +1,9 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class Equals extends Base { private $field2; @@ -24,7 +12,6 @@ class Equals extends Base public function __construct($field1, $field2, $error_message) { parent::__construct($field1, $error_message); - $this->field2 = $field2; } @@ -33,7 +20,9 @@ class Equals extends Base { if (isset($data[$this->field]) && $data[$this->field] !== '') { - if (! isset($data[$this->field2])) return false; + if (! isset($data[$this->field2])) { + return false; + } return $data[$this->field] === $data[$this->field2]; } diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Exists.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Exists.php index 8f851ae..f77ecce 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Exists.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Exists.php @@ -1,16 +1,8 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; +use PDO; use SimpleValidator\Base; /** @@ -23,7 +15,7 @@ class Exists extends Base private $table; - public function __construct($field, $error_message, \PDO $pdo, $table, $key = '') + public function __construct($field, $error_message, PDO $pdo, $table, $key = '') { parent::__construct($field, $error_message); @@ -38,21 +30,14 @@ class Exists extends Base if (! isset($data[$this->field]) || '' === $data[$this->field]) { return true; } + if ($this->key === '') { $this->key = $this->field; } $rq = $this->pdo->prepare('SELECT COUNT(*) FROM '.$this->table.' WHERE '.$this->key.'=?'); - $rq->execute(array( - $data[$this->field] - )); + $rq->execute(array($data[$this->field])); - $result = $rq->fetch(\PDO::FETCH_NUM); - - if (isset($result[0]) && $result[0] >= '1') { - return true; - } - - return false; + return $rq->fetchColumn() >= 1; } } \ No newline at end of file diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/GreaterThan.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/GreaterThan.php index e038cb6..e182716 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/GreaterThan.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/GreaterThan.php @@ -1,14 +1,5 @@ min = $min; } - public function execute(array $data) { if (isset($data[$this->field]) && $data[$this->field] !== '') { @@ -33,4 +22,4 @@ class GreaterThan extends Base return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/InArray.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/InArray.php index 2beedc3..e236ecf 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/InArray.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/InArray.php @@ -1,14 +1,5 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Integer.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Integer.php index 150558a..3f32274 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Integer.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Integer.php @@ -1,21 +1,9 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class Integer extends Base { public function execute(array $data) @@ -25,7 +13,6 @@ class Integer extends Base if (is_string($data[$this->field])) { if ($data[$this->field][0] === '-') { - return ctype_digit(substr($data[$this->field], 1)); } @@ -34,9 +21,9 @@ class Integer extends Base else { return is_int($data[$this->field]); - } + } } return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Ip.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Ip.php index 48afe56..364231b 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Ip.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Ip.php @@ -1,33 +1,19 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class Ip extends Base { public function execute(array $data) { if (isset($data[$this->field]) && $data[$this->field] !== '') { - if (! filter_var($data[$this->field], FILTER_VALIDATE_IP)) { - return false; } } return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Length.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Length.php index 36e50b3..d26cb74 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Length.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Length.php @@ -1,27 +1,14 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class Length extends Base { private $min; private $max; - public function __construct($field, $error_message, $min, $max) { parent::__construct($field, $error_message); @@ -30,7 +17,6 @@ class Length extends Base $this->max = $max; } - public function execute(array $data) { if (isset($data[$this->field]) && $data[$this->field] !== '') { @@ -38,11 +24,10 @@ class Length extends Base $length = mb_strlen($data[$this->field], 'UTF-8'); if ($length < $this->min || $length > $this->max) { - return false; } } return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MacAddress.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MacAddress.php index d934841..7652db8 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MacAddress.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MacAddress.php @@ -1,21 +1,9 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class MacAddress extends Base { public function execute(array $data) @@ -24,14 +12,17 @@ class MacAddress extends Base $groups = explode(':', $data[$this->field]); - if (count($groups) !== 6) return false; + if (count($groups) !== 6) { + return false; + } foreach ($groups as $group) { - - if (! ctype_xdigit($group)) return false; + if (! ctype_xdigit($group)) { + return false; + } } } return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MaxLength.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MaxLength.php index d8e032b..7dd9fa4 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MaxLength.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MaxLength.php @@ -1,34 +1,19 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class MaxLength extends Base { private $max; - public function __construct($field, $error_message, $max) { parent::__construct($field, $error_message); - $this->max = $max; } - public function execute(array $data) { if (isset($data[$this->field]) && $data[$this->field] !== '') { @@ -36,11 +21,10 @@ class MaxLength extends Base $length = mb_strlen($data[$this->field], 'UTF-8'); if ($length > $this->max) { - return false; } } return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MinLength.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MinLength.php index 4b7f7d2..0a34646 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MinLength.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/MinLength.php @@ -1,34 +1,19 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class MinLength extends Base { private $min; - public function __construct($field, $error_message, $min) { parent::__construct($field, $error_message); - $this->min = $min; } - public function execute(array $data) { if (isset($data[$this->field]) && $data[$this->field] !== '') { @@ -36,11 +21,10 @@ class MinLength extends Base $length = mb_strlen($data[$this->field], 'UTF-8'); if ($length < $this->min) { - return false; } } return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEquals.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEquals.php index 0069633..f4bb1c3 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEquals.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotEquals.php @@ -1,14 +1,5 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; @@ -20,7 +11,6 @@ class NotEquals extends Base { private $field2; - public function __construct($field1, $field2, $error_message) { parent::__construct($field1, $error_message); @@ -28,16 +18,17 @@ class NotEquals extends Base $this->field2 = $field2; } - public function execute(array $data) { if (isset($data[$this->field]) && $data[$this->field] !== '') { - if (! isset($data[$this->field2])) return true; + if (! isset($data[$this->field2])) { + return true; + } return $data[$this->field] !== $data[$this->field2]; } - + return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotInArray.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotInArray.php index d5b74fa..3fd6f27 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotInArray.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/NotInArray.php @@ -1,14 +1,5 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; class NotInArray extends InArray diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Numeric.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Numeric.php index a958df1..9a235dc 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Numeric.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Numeric.php @@ -1,21 +1,9 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class Numeric extends Base { public function execute(array $data) @@ -23,11 +11,10 @@ class Numeric extends Base if (isset($data[$this->field]) && $data[$this->field] !== '') { if (! is_numeric($data[$this->field])) { - return false; } } return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Range.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Range.php index 1d71b92..94cacac 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Range.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Range.php @@ -1,27 +1,14 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class Range extends Base { private $min; private $max; - public function __construct($field, $error_message, $min, $max) { parent::__construct($field, $error_message); @@ -30,18 +17,15 @@ class Range extends Base $this->max = $max; } - public function execute(array $data) { if (isset($data[$this->field]) && $data[$this->field] !== '') { if (! is_numeric($data[$this->field])) { - return false; } if ($data[$this->field] < $this->min || $data[$this->field] > $this->max) { - return false; } } diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Required.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Required.php index e7ef271..5a987ee 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Required.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Required.php @@ -1,30 +1,17 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - */ class Required extends Base { public function execute(array $data) { if (! isset($data[$this->field]) || $data[$this->field] === '') { - return false; } return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Unique.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Unique.php index fe47980..31515d2 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Unique.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Unique.php @@ -1,30 +1,17 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; +use PDO; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - * @author Olivier Maridat - */ class Unique extends Base { private $pdo; private $primary_key; private $table; - - public function __construct($field, $error_message, \PDO $pdo, $table, $primary_key = 'id') + public function __construct($field, $error_message, PDO $pdo, $table, $primary_key = 'id') { parent::__construct($field, $error_message); @@ -33,38 +20,33 @@ class Unique extends Base $this->table = $table; } - public function execute(array $data) { - if (! is_array($this->field)) { - $this->field = array($this->field); - } - $fields = array(); - $parameters = array(); - foreach($this->field AS $field) { - if (! isset($data[$field]) || $data[$field] === '') { - return true; - } - $fields[] = $field; - $parameters[] = $data[$field]; - } - - if (isset($data[$this->primary_key])) { - $parameters[] = $data[$this->primary_key]; - } + if (isset($data[$this->field]) && $data[$this->field] !== '') { - $rq = $this->pdo->prepare( - 'SELECT COUNT(*) FROM '.$this->table.' WHERE '.implode('=? AND ', $fields).'=?'.(isset($data[$this->primary_key]) ? ' AND '.$this->primary_key.'!=?' : '') - ); - - $rq->execute($parameters); - - $result = $rq->fetch(\PDO::FETCH_NUM); - - if (isset($result[0]) && $result[0] === '1') { - return false; - } - - return true; + if (! isset($data[$this->primary_key])) { + + $rq = $this->pdo->prepare('SELECT COUNT(*) FROM '.$this->table.' WHERE '.$this->field.'=?'); + $rq->execute(array($data[$this->field])); + + } + else { + + $rq = $this->pdo->prepare( + 'SELECT COUNT(*) FROM '.$this->table.' + WHERE '.$this->field.'=? AND '.$this->primary_key.' != ?' + ); + + $rq->execute(array($data[$this->field], $data[$this->primary_key])); + } + + $result = $rq->fetchColumn(); + + if ($result == 1) { // Postgresql returns an integer but other database returns a string '1' + return false; + } + } + + return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Version.php b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Version.php index 273a28a..4a3ad25 100644 --- a/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Version.php +++ b/vendor/fguillot/simple-validator/src/SimpleValidator/Validators/Version.php @@ -1,32 +1,18 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace SimpleValidator\Validators; use SimpleValidator\Base; -/** - * @author Frédéric Guillot - * @link http://semver.org/ - */ class Version extends Base { public function execute(array $data) { if (isset($data[$this->field]) && $data[$this->field] !== '') { - $pattern = '/^[0-9]+\.[0-9]+\.[0-9]+([+-][^+-][0-9A-Za-z-.]*)?$/'; return (bool) preg_match($pattern, $data[$this->field]); } return true; } -} \ No newline at end of file +} diff --git a/vendor/fguillot/simple-validator/tests/UniqueValidatorTest.php b/vendor/fguillot/simple-validator/tests/UniqueValidatorTest.php index 556f0d7..a5cc104 100644 --- a/vendor/fguillot/simple-validator/tests/UniqueValidatorTest.php +++ b/vendor/fguillot/simple-validator/tests/UniqueValidatorTest.php @@ -30,54 +30,9 @@ class UniqueValidatorTest extends PHPUnit_Framework_TestCase $pdo->exec("INSERT INTO mytable VALUES ('2', 'titi')"); $this->assertFalse($v->execute(array('toto' => 'titi'))); - + $this->assertTrue($v->execute(array('toto' => 'titi', 'id' => '2'))); $this->assertFalse($v->execute(array('toto' => 'truc', 'id' => '2'))); } - - public function testValidatorWithArray() - { - $pdo = new PDO('sqlite::memory:'); - $pdo->exec('CREATE TABLE mytable (id INTEGER, toto TEXT, tata TEXT)'); - - $message = 'field must be unique'; - - $v = new Unique(array('toto', 'tata'), $message, $pdo, 'mytable'); - - $this->assertEquals($message, $v->getErrorMessage()); - - $this->assertTrue($v->execute(array('toto' => ''))); - $this->assertTrue($v->execute(array('toto' => null))); - - $this->assertTrue($v->execute(array('toto' => 'bidule'))); - $this->assertTrue($v->execute(array('toto' => 'bidule', 'tata' => 'machin'))); - $this->assertTrue($v->execute(array('toto' => 'bidule', 'toutou' => 'machin'))); - - $pdo->exec("INSERT INTO mytable VALUES ('1', 'truc', 'muche')"); - - $this->assertTrue($v->execute(array('toto' => 'truc'))); - $this->assertTrue($v->execute(array('toto' => 'bidule'))); - - $this->assertTrue($v->execute(array('toto' => 'bidule', 'tata' => 'miouch'))); - $this->assertTrue($v->execute(array('toto' => 'bidule', 'tata' => 'muche'))); - $this->assertTrue($v->execute(array('toto' => 'bidule', 'toutou' => 'muche'))); - - $this->assertFalse($v->execute(array('toto' => 'truc', 'tata' => 'muche'))); - $this->assertTrue($v->execute(array('toto' => 'truc', 'tata' => 'miouch'))); - - $pdo->exec("INSERT INTO mytable VALUES ('2', 'bidule', 'machin')"); - - $this->assertTrue($v->execute(array('toto' => 'bidule'))); - $this->assertTrue($v->execute(array('toto' => 'truc'))); - - $this->assertTrue($v->execute(array('toto' => 'bidule', 'tata' => 'muche'))); - $this->assertFalse($v->execute(array('toto' => 'bidule', 'tata' => 'machin'))); - $this->assertTrue($v->execute(array('toto' => 'bidule', 'tata' => 'muche', 'id' => '2'))); - $this->assertTrue($v->execute(array('toto' => 'bidule', 'tata' => 'machin', 'id' => '2'))); - - $this->assertTrue($v->execute(array('toto' => 'truc', 'id' => '2'))); - $this->assertFalse($v->execute(array('toto' => 'truc', 'tata' => 'muche', 'id' => '2'))); - $this->assertTrue($v->execute(array('toto' => 'truc', 'tata' => 'miouch', 'id' => '2'))); - } } \ No newline at end of file