aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-10-22 12:53:00 +0200
committerLukas Reschke <lukas@owncloud.com>2014-10-22 12:53:00 +0200
commit3ee491b0de88e44c39387a2eb25915597e90308c (patch)
tree15bb34f79be9e9149cdafc9189a34e987a98c4d1
parent039603e10a36e476b7ee06548b0a8c62d6e9419c (diff)
parentcd6de9b8e41c584092821d0a0071351b6426ba32 (diff)
downloadnextcloud-server-3ee491b0de88e44c39387a2eb25915597e90308c.tar.gz
nextcloud-server-3ee491b0de88e44c39387a2eb25915597e90308c.zip
Merge pull request #11249 from owncloud/backport-11032-stable5
Do only follow HTTP and HTTPS redirects
-rw-r--r--apps/files/ajax/newfile.php11
-rw-r--r--lib/user/http.php3
-rwxr-xr-xlib/util.php90
3 files changed, 60 insertions, 44 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index a68716f5db3..56b741544f1 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -60,7 +60,16 @@ if($source) {
exit();
}
- $ctx = stream_context_create(null, array('notification' =>'progress'));
+ $contextArray = array(
+ 'http' => array(
+ 'timeout' => 10,
+ 'follow_location' => false, // Do not follow the location since we can't limit the protocol
+ ),
+ 'ssl' => array(
+ 'disable_compression' => true
+ )
+ );
+ $ctx = stream_context_create($contextArray, array('notification' =>'progress'));
$sourceStream=fopen($source, 'rb', false, $ctx);
$target=$dir.'/'.$filename;
$result=\OC\Files\Filesystem::file_put_contents($target, $sourceStream);
diff --git a/lib/user/http.php b/lib/user/http.php
index 944ede73a0b..71e3fbd59a4 100644
--- a/lib/user/http.php
+++ b/lib/user/http.php
@@ -72,7 +72,8 @@ class OC_User_HTTP extends OC_User_Backend {
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$password);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
+ curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
+ curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
diff --git a/lib/util.php b/lib/util.php
index 13231b8df21..c486ff6a01b 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -798,54 +798,60 @@ class OC_Util {
*/
public static function getUrlContent($url){
+ if(stripos($url, 'https://') === 0 || stripos($url, 'http://') === 0) {
+ if (function_exists('curl_init')) {
+
+ $curl = curl_init();
+
+ curl_setopt($curl, CURLOPT_HEADER, 0);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
+ curl_setopt($curl, CURLOPT_URL, $url);
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
+ curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
+ curl_setopt($curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
+ curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
+
+ curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler");
+ if(OC_Config::getValue('proxy', '')<>'') {
+ curl_setopt($curl, CURLOPT_PROXY, OC_Config::getValue('proxy'));
+ }
+ if(OC_Config::getValue('proxyuserpwd', '')<>'') {
+ curl_setopt($curl, CURLOPT_PROXYUSERPWD, OC_Config::getValue('proxyuserpwd'));
+ }
+ $data = curl_exec($curl);
+ curl_close($curl);
- if (function_exists('curl_init')) {
-
- $curl = curl_init();
-
- curl_setopt($curl, CURLOPT_HEADER, 0);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
- curl_setopt($curl, CURLOPT_URL, $url);
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
-
- curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler");
- if(OC_Config::getValue('proxy', '')<>'') {
- curl_setopt($curl, CURLOPT_PROXY, OC_Config::getValue('proxy'));
- }
- if(OC_Config::getValue('proxyuserpwd', '')<>'') {
- curl_setopt($curl, CURLOPT_PROXYUSERPWD, OC_Config::getValue('proxyuserpwd'));
- }
- $data = curl_exec($curl);
- curl_close($curl);
-
- } else {
- $contextArray = null;
-
- if(OC_Config::getValue('proxy', '')<>'') {
- $contextArray = array(
- 'http' => array(
- 'timeout' => 10,
- 'proxy' => OC_Config::getValue('proxy')
- )
- );
} else {
- $contextArray = array(
- 'http' => array(
- 'timeout' => 10
- )
- );
- }
+ $contextArray = null;
+
+ if(OC_Config::getValue('proxy', '')<>'') {
+ $contextArray = array(
+ 'http' => array(
+ 'follow_location' => false, // Do not follow the location since we can't limit the protocol
+ 'timeout' => 10,
+ 'proxy' => OC_Config::getValue('proxy')
+ )
+ );
+ } else {
+ $contextArray = array(
+ 'http' => array(
+ 'follow_location' => false, // Do not follow the location since we can't limit the protocol
+ 'timeout' => 10
+ )
+ );
+ }
- $ctx = stream_context_create(
- $contextArray
- );
- $data=@file_get_contents($url, 0, $ctx);
+ $ctx = stream_context_create(
+ $contextArray
+ );
+ $data=@file_get_contents($url, 0, $ctx);
+ }
+ return $data;
}
- return $data;
+ return false;
}
/**