diff --git a/composer.json b/composer.json index 9ec0df1..4d80a28 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,13 @@ { - "name": "fin1te/safecurl", + "name": "barmat/safecurl", "description": "A drop-in replacement for 'curl_exec', designed to prevent SSRF attacks.", "keywords": ["curl", "safecurl", "safe", "ssrf", "websec"], "license": "MIT", "authors": [ + { + "name": "Matt Barry", + "email": "mattbarrah@gmail.com" + }, { "name": "Jack W", "email": "jack@fin1te.net" diff --git a/src/fin1te/SafeCurl/SafeCurl.php b/src/fin1te/SafeCurl/SafeCurl.php index b7dbef4..6f3a2a7 100644 --- a/src/fin1te/SafeCurl/SafeCurl.php +++ b/src/fin1te/SafeCurl/SafeCurl.php @@ -1,6 +1,7 @@ options; @@ -73,7 +74,7 @@ public function getOptions() { /** * Sets Options * - * @param $options SafeCurl\Options + * @param $options Options */ public function setOptions(Options $options) { $this->options = $options; @@ -97,27 +98,18 @@ protected function init() { } /** - * Exectutes a cURL request, whilst checking that the + * Exectutes a cURL request, whilst checking that the * URL abides by our whitelists/blacklists * * @param $url string * @param $curlHandle resource optional - Incase called on an object rather than statically - * @param $options SafeCurl\Options optional - * + * @param $options Options optional * @return bool + * @throws InvalidURLException + * @throws \fin1te\SafeCurl\Exception */ public static function execute($url, $curlHandle = null, Options $options = null) { - //Check if we've been called staticly or not - if (isset($this) && get_class($this) == __CLASS__) { - $safeCurl = $this; - //Get the cURL handle, if it wasn't passed in - if (!is_resource($curlHandle) || get_resource_type($curlHandle) != 'curl') { - $curlHandle = $this->getCurlHandle(); - } - } else { - $safeCurl = new SafeCurl($curlHandle, $options); - } - + $safeCurl = new SafeCurl($curlHandle, $options); //Backup the existing URL $originalUrl = $url; diff --git a/src/fin1te/SafeCurl/Url.php b/src/fin1te/SafeCurl/Url.php index 911d482..995edfe 100644 --- a/src/fin1te/SafeCurl/Url.php +++ b/src/fin1te/SafeCurl/Url.php @@ -199,7 +199,7 @@ public static function buildUrl($parts) { : ''; $url .= (!empty($parts['path'])) - ? '/' . rawurlencode(substr($parts['path'], 1)) + ? str_replace('%2F', '/', rawurlencode($parts['path'])) : ''; //The query string is difficult to encode properly