Skip to content

Commit afb299d

Browse files
committed
check if the cookie file is writable #114
1 parent 4952e36 commit afb299d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/RequestResolvers/Curl.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66
namespace Embed\RequestResolvers;
77

8+
use Embed\Exceptions\EmbedException;
9+
810
class Curl implements RequestResolverInterface
911
{
1012
protected static $tmpCookies;
@@ -113,6 +115,14 @@ protected function resolve()
113115

114116
if (!self::$tmpCookies) {
115117
self::$tmpCookies = str_replace('//', '/', sys_get_temp_dir().'/embed-cookies.txt');
118+
119+
if (is_file(self::$tmpCookies)) {
120+
if (!is_writable(self::$tmpCookies)) {
121+
throw new EmbedException(sprintf('The temporary cookies file "%s" is not writable', self::$tmpCookies));
122+
}
123+
} elseif (!is_writable(dirname(self::$tmpCookies))) {
124+
throw new EmbedException(sprintf('The temporary folder "%s" is not writable', dirname(self::$tmpCookies)));
125+
}
116126
}
117127

118128
$connection = curl_init();

0 commit comments

Comments
 (0)