Skip to content

Commit 89e21c3

Browse files
committed
Merge branch 'master' of https://github.com/oscarotero/Embed
2 parents 3715c06 + 3f1893c commit 89e21c3

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/ImageInfo/Curl.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,19 @@ public function __construct($url, $finfo, array $config = null)
103103
$this->config = array_replace($this->config, $config);
104104
}
105105

106-
curl_setopt_array($this->connection, [
106+
$options = [
107107
CURLOPT_RETURNTRANSFER => false,
108108
CURLOPT_FOLLOWLOCATION => true,
109109
CURLOPT_URL => $url,
110110
CURLOPT_HEADERFUNCTION => [$this, 'headerCallback'],
111111
CURLOPT_WRITEFUNCTION => [$this, 'writeCallback'],
112-
] + $this->config);
112+
] + $this->config;
113+
114+
if (ini_get('open_basedir') || filter_var(ini_get('safe_mode'), FILTER_VALIDATE_BOOLEAN)) {
115+
$options[CURLOPT_FOLLOWLOCATION] = false;
116+
}
117+
118+
curl_setopt_array($this->connection, $options);
113119
}
114120

115121
/**
@@ -148,10 +154,10 @@ public function getUrl()
148154

149155
/**
150156
* Callback used to save the headers.
151-
*
157+
*
152158
* @param resource $connection
153159
* @param string $string
154-
*
160+
*
155161
* @return int
156162
*/
157163
public function headerCallback($connection, $string)

src/RequestResolvers/Curl.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,21 @@ protected function resolve()
150150

151151
$connection = curl_init();
152152

153-
curl_setopt_array($connection, [
153+
$options = [
154154
CURLOPT_RETURNTRANSFER => false,
155155
CURLOPT_FOLLOWLOCATION => true,
156156
CURLOPT_URL => $this->url,
157157
CURLOPT_COOKIEJAR => self::$tmpCookies,
158158
CURLOPT_COOKIEFILE => self::$tmpCookies,
159159
CURLOPT_HEADERFUNCTION => [$this, 'headerCallback'],
160160
CURLOPT_WRITEFUNCTION => [$this, 'writeCallback'],
161-
] + $this->config);
161+
] + $this->config;
162+
163+
if (ini_get('open_basedir') || filter_var(ini_get('safe_mode'), FILTER_VALIDATE_BOOLEAN)) {
164+
$options[CURLOPT_FOLLOWLOCATION] = false;
165+
}
166+
167+
curl_setopt_array($connection, $options);
162168

163169
$result = curl_exec($connection);
164170

0 commit comments

Comments
 (0)