aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-03-10 23:04:17 +0100
committerGravatar GitHub <noreply@github.com> 2024-03-10 23:04:17 +0100
commitd0072b9fb73a6582c98c7b5a44daf2d6ca39636e (patch)
treebf1992ca2ca7c6ae65c5a63bdb66bf2f4b7850a6 /lib
parent01eaaed9bb2268bc1d0509ca4f33d4b075634c9a (diff)
Refactor some cURL options and use CURLOPT_USERPWD (#6177)
* Refactor some cURL options and use CURLOPT_USERPWD fix https://github.com/FreshRSS/FreshRSS/issues/6176 * Fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/lib_rss.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 880b4e65a..6669b36dc 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -303,9 +303,10 @@ function sensitive_log($log) {
/**
* @param array<string,mixed> $attributes
+ * @param array<int,mixed> $curl_options
* @throws FreshRSS_Context_Exception
*/
-function customSimplePie(array $attributes = array()): SimplePie {
+function customSimplePie(array $attributes = [], array $curl_options = []): SimplePie {
$limits = FreshRSS_Context::systemConf()->limits;
$simplePie = new SimplePie();
$simplePie->set_useragent(FRESHRSS_USERAGENT);
@@ -318,7 +319,7 @@ function customSimplePie(array $attributes = array()): SimplePie {
$feed_timeout = empty($attributes['timeout']) || !is_numeric($attributes['timeout']) ? 0 : (int)$attributes['timeout'];
$simplePie->set_timeout($feed_timeout > 0 ? $feed_timeout : $limits['timeout']);
- $curl_options = FreshRSS_Context::systemConf()->curl_options;
+ $curl_options = array_replace(FreshRSS_Context::systemConf()->curl_options, $curl_options);
if (isset($attributes['ssl_verify'])) {
$curl_options[CURLOPT_SSL_VERIFYHOST] = $attributes['ssl_verify'] ? 2 : 0;
$curl_options[CURLOPT_SSL_VERIFYPEER] = (bool)$attributes['ssl_verify'];
@@ -482,8 +483,9 @@ function enforceHttpEncoding(string $html, string $contentType = ''): string {
/**
* @param string $type {html,json,opml,xml}
* @param array<string,mixed> $attributes
+ * @param array<int,mixed> $curl_options
*/
-function httpGet(string $url, string $cachePath, string $type = 'html', array $attributes = []): string {
+function httpGet(string $url, string $cachePath, string $type = 'html', array $attributes = [], array $curl_options = []): string {
$limits = FreshRSS_Context::systemConf()->limits;
$feed_timeout = empty($attributes['timeout']) || !is_numeric($attributes['timeout']) ? 0 : intval($attributes['timeout']);
@@ -548,6 +550,9 @@ function httpGet(string $url, string $cachePath, string $type = 'html', array $a
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'DEFAULT@SECLEVEL=1');
}
}
+
+ curl_setopt_array($ch, $curl_options);
+
$body = curl_exec($ch);
$c_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$c_content_type = '' . curl_getinfo($ch, CURLINFO_CONTENT_TYPE);