From 994909900071d7827b3638cb80037241c9b0bac3 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 23 Oct 2015 18:06:09 -0400 Subject: [PATCH] Update picofeed to handle HTTP 303 redirects --- composer.json | 2 +- vendor/composer/installed.json | 12 ++++++------ .../fguillot/picofeed/lib/PicoFeed/Client/Client.php | 12 ++++++++++++ .../fguillot/picofeed/lib/PicoFeed/Client/Curl.php | 4 ++-- .../picofeed/lib/PicoFeed/Rules/.wired.com.php | 2 +- .../picofeed/lib/PicoFeed/Rules/networkworld.com.php | 2 +- .../picofeed/lib/PicoFeed/Rules/opensource.com.php | 12 ++++++++++++ .../picofeed/lib/PicoFeed/Rules/recode.net.php | 1 + 8 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 vendor/fguillot/picofeed/lib/PicoFeed/Rules/opensource.com.php diff --git a/composer.json b/composer.json index f78f447..5678656 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "fguillot/simple-validator": "v1.0.0", "fguillot/json-rpc": "v1.0.2", "fguillot/picodb": "v1.0.2", - "fguillot/picofeed": "v0.1.14" + "fguillot/picofeed": "v0.1.15" }, "require-dev": { "phpunit/phpunit": "4.8.3", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 10349f4..f96d709 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -116,17 +116,17 @@ }, { "name": "fguillot/picofeed", - "version": "v0.1.14", - "version_normalized": "0.1.14.0", + "version": "v0.1.15", + "version_normalized": "0.1.15.0", "source": { "type": "git", "url": "https://github.com/fguillot/picoFeed.git", - "reference": "4cff44c2b67888ab4d5bc9ce57b5777e15818efc" + "reference": "ee91bcfd4be93d38ae5f870723c652a9d795c75f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fguillot/picoFeed/zipball/4cff44c2b67888ab4d5bc9ce57b5777e15818efc", - "reference": "4cff44c2b67888ab4d5bc9ce57b5777e15818efc", + "url": "https://api.github.com/repos/fguillot/picoFeed/zipball/ee91bcfd4be93d38ae5f870723c652a9d795c75f", + "reference": "ee91bcfd4be93d38ae5f870723c652a9d795c75f", "shasum": "" }, "require": { @@ -140,7 +140,7 @@ "suggest": { "ext-curl": "PicoFeed will use cURL if present" }, - "time": "2015-10-21 23:38:45", + "time": "2015-10-23 21:59:31", "bin": [ "picofeed" ], diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php index a3bb896..3c64ce5 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Client.php @@ -653,4 +653,16 @@ abstract class Client return $this; } + + /** + * Return true if the HTTP status code is a redirection + * + * @access protected + * @param integer $code + * @return boolean + */ + public function isRedirection($code) + { + return $code == 301 || $code == 302 || $code == 303 || $code == 307; + } } diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php index 2063761..b07685f 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Client/Curl.php @@ -295,7 +295,7 @@ class Curl extends Client list($status, $headers) = HttpHeaders::parse(explode("\n", $this->response_headers[$this->response_headers_count - 1])); - if ($follow_location && ($status == 301 || $status == 302)) { + if ($follow_location && $this->isRedirection($status)) { return $this->handleRedirection($headers['Location']); } @@ -332,7 +332,7 @@ class Curl extends Client $result = $this->doRequest(false); - if ($result['status'] == 301 || $result['status'] == 302) { + if ($this->isRedirection($result['status'])) { $this->url = Url::resolve($result['headers']['Location'], $this->url); $this->body = ''; $this->body_length = 0; diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.wired.com.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.wired.com.php index 3e40e40..b6a1b96 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.wired.com.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/.wired.com.php @@ -11,7 +11,7 @@ return array( '//*[@id="linker_widget"]', '//*[@class="credit"]', '//div[@data-js="slideCount"]', - '//span[@class="visually-hidden"]', + '//*[contains(@class="visually-hidden")]', '//*[@data-slide-number="_endslate"]', '//*[@id="related"]', '//*[contains(@class, "bio")]', diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/networkworld.com.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/networkworld.com.php index 82982c6..dbb63a2 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/networkworld.com.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/networkworld.com.php @@ -5,7 +5,7 @@ return array( '%.*%' => array( 'test_url' => 'http://www.networkworld.com/article/2986764/smartphones/samsung-tried-to-troll-apple-fans-waiting-in-line-for-the-iphone-6s.html#tk.rss_all', 'body' => array( - '//figure/img', + '//figure/img[@class="hero-img"]', '//section[@class="deck"]', '//div[@itemprop="articleBody"]', ), diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/opensource.com.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/opensource.com.php new file mode 100644 index 0000000..52c2ffa --- /dev/null +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/opensource.com.php @@ -0,0 +1,12 @@ + array( + '%.*%' => array( + 'test_url' => 'http://opensource.com/life/15/10/how-internet-things-will-change-way-we-think', + 'body' => array( + '//img[@class="image-full-size"]', + '//div[contains(@class="field-type-text-with-summary")]', + ), + ) + ) +); diff --git a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/recode.net.php b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/recode.net.php index 1782729..4dce0b0 100644 --- a/vendor/fguillot/picofeed/lib/PicoFeed/Rules/recode.net.php +++ b/vendor/fguillot/picofeed/lib/PicoFeed/Rules/recode.net.php @@ -13,6 +13,7 @@ return array( '//script', '//div[contains(@class,"sharedaddy")]', '//div[@class="post-send-off"]', + '//div[contains(@class,"inner-related-article")]', ), ), ),