Jelajahi Sumber

CURLOPT_FOLLOWLOCATION open_basedir bug (#1657)

CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set
https://github.com/FreshRSS/FreshRSS/issues/1655#issuecomment-334999448
https://stackoverflow.com/questions/6918623/curlopt-followlocation-cannot-be-activated
Alexandre Alapetite 8 tahun lalu
induk
melakukan
1eb19409b5
3 mengubah file dengan 19 tambahan dan 14 penghapusan
  1. 2 0
      CHANGELOG.md
  2. 15 12
      app/Models/Feed.php
  3. 2 2
      lib/favicons.php

+ 2 - 0
CHANGELOG.md

@@ -4,6 +4,8 @@
 
 * SimplePie
 	* Remove "SimplePie" name from HTTP User-Agent string [#1656](https://github.com/FreshRSS/FreshRSS/pull/1656)
+* Bug fixing
+	* Work-around for `CURLOPT_FOLLOWLOCATION` `open_basedir` bug in favicons and PubSubHubbub [#1655](https://github.com/FreshRSS/FreshRSS/issues/1655)
 * Misc.
 	* Travis translation validation tool [#1653](https://github.com/FreshRSS/FreshRSS/pull/1653)
 

+ 15 - 12
app/Models/Feed.php

@@ -481,18 +481,21 @@ class FreshRSS_Feed extends Minz_Model {
 			}
 			$ch = curl_init();
 			curl_setopt_array($ch, array(
-				CURLOPT_URL => $hubJson['hub'],
-				CURLOPT_FOLLOWLOCATION => true,
-				CURLOPT_RETURNTRANSFER => true,
-				CURLOPT_USERAGENT => FRESHRSS_USERAGENT,
-				CURLOPT_POSTFIELDS => http_build_query(array(
-					'hub.verify' => 'sync',
-					'hub.mode' => $state ? 'subscribe' : 'unsubscribe',
-					'hub.topic' => $url,
-					'hub.callback' => $callbackUrl,
-					))
-				)
-			);
+					CURLOPT_URL => $hubJson['hub'],
+					CURLOPT_RETURNTRANSFER => true,
+					CURLOPT_POSTFIELDS => http_build_query(array(
+						'hub.verify' => 'sync',
+						'hub.mode' => $state ? 'subscribe' : 'unsubscribe',
+						'hub.topic' => $url,
+						'hub.callback' => $callbackUrl,
+						)),
+					CURLOPT_USERAGENT => FRESHRSS_USERAGENT,
+					CURLOPT_MAXREDIRS => 10,
+				));
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);	//Keep option separated for open_basedir bug
+			if (defined('CURLOPT_ENCODING')) {
+				curl_setopt($ch, CURLOPT_ENCODING, '');	//Enable all encodings
+			}
 			$response = curl_exec($ch);
 			$info = curl_getinfo($ch);
 

+ 2 - 2
lib/favicons.php

@@ -31,12 +31,12 @@ function downloadHttp(&$url, $curlOptions = array()) {
 	}
 	$ch = curl_init($url);
 	curl_setopt_array($ch, array(
-			CURLOPT_FOLLOWLOCATION => true,
-			CURLOPT_MAXREDIRS => 10,
 			CURLOPT_RETURNTRANSFER => true,
 			CURLOPT_TIMEOUT => 15,
 			CURLOPT_USERAGENT => FRESHRSS_USERAGENT,
+			CURLOPT_MAXREDIRS => 10,
 		));
+	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);	//Keep option separated for open_basedir bug
 	if (defined('CURLOPT_ENCODING')) {
 		curl_setopt($ch, CURLOPT_ENCODING, '');	//Enable all encodings
 	}