aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-03-04 11:18:56 +0100
committerGravatar GitHub <noreply@github.com> 2023-03-04 11:18:56 +0100
commit32acd6c13e92971714aa5ba47827cb3410c4cddf (patch)
tree6edde59fb0830bc8a3d88e27ee151b233592e6ce /lib
parent44f72889a589758da1b026a5288e23987a525095 (diff)
SimplePie use single constant for default HTTP Accept header (#5083)
* Use single constant for default SimplePie HTTP Accept And add missing headers in `SimplePie_Locator::body()` Follow-up of https://github.com/simplepie/simplepie/commit/5d966b9f64a6034f89b019152d7cad9059f8819f * Update SimplePie default HTTP Accept Fix https://github.com/FreshRSS/FreshRSS/pull/5079#issuecomment-1421619176 The `*/*` breaks Mastodon content negotiation * Revert "Update SimplePie default HTTP Accept" This reverts commit 13a5a5cb3b2fa6bdd57be8b3f84dc37ed814ccf6. * Same as upstream
Diffstat (limited to 'lib')
-rw-r--r--lib/SimplePie/SimplePie.php10
-rw-r--r--lib/SimplePie/SimplePie/Locator.php8
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/SimplePie/SimplePie.php b/lib/SimplePie/SimplePie.php
index 9983f577e..c0b2e24f6 100644
--- a/lib/SimplePie/SimplePie.php
+++ b/lib/SimplePie/SimplePie.php
@@ -418,6 +418,12 @@ define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16);
*/
class SimplePie
{
+
+ /**
+ * @internal Default value of the HTTP Accept header when fetching/locating feeds
+ */
+ public const DEFAULT_HTTP_ACCEPT_HEADER = 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1';
+
/**
* @var array Raw data
* @access private
@@ -1690,7 +1696,7 @@ class SimplePie
else
{
$headers = array(
- 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
+ 'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
);
if (isset($this->data['headers']['last-modified']))
{
@@ -1754,7 +1760,7 @@ class SimplePie
else
{
$headers = array(
- 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
+ 'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
);
$file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options, $this->syslog_enabled));
}
diff --git a/lib/SimplePie/SimplePie/Locator.php b/lib/SimplePie/SimplePie/Locator.php
index c5fae0579..10b50cadf 100644
--- a/lib/SimplePie/SimplePie/Locator.php
+++ b/lib/SimplePie/SimplePie/Locator.php
@@ -256,7 +256,7 @@ class SimplePie_Locator
{
$this->checked_feeds++;
$headers = array(
- 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
+ 'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
);
$feed = $this->registry->create('File', array($href, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options));
if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed, true))
@@ -386,7 +386,7 @@ class SimplePie_Locator
$this->checked_feeds++;
$headers = array(
- 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
+ 'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
);
$feed = $this->registry->create('File', array($value, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options));
if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
@@ -414,9 +414,9 @@ class SimplePie_Locator
{
$this->checked_feeds++;
$headers = array(
- 'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
+ 'Accept' => SimplePie::DEFAULT_HTTP_ACCEPT_HEADER,
);
- $feed = $this->registry->create('File', array($value, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen, $this->curl_options));
+ $feed = $this->registry->create('File', array($value, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen, $this->curl_options));
if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed))
{
return array($feed);