Skip to content
Snippets Groups Projects
Commit 6d8d90cf authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

fixed an error in location redirects

parent fde6e1ec
No related branches found
No related tags found
1 merge request!15fixed an error in location redirects
...@@ -132,13 +132,14 @@ class ProxyController extends Controller ...@@ -132,13 +132,14 @@ class ProxyController extends Controller
$targetUrl = str_replace("<<SLASH>>", "/", $url); $targetUrl = str_replace("<<SLASH>>", "/", $url);
$targetUrl = str_rot13(base64_decode($targetUrl)); $targetUrl = str_rot13(base64_decode($targetUrl));
$this->password = $password; $this->password = $password;
// Hash Value under which a possible cached file would've been stored // Hash Value under which a possible cached file would've been stored
$hash = md5($targetUrl); $hash = md5($targetUrl);
$result = []; $result = [];
$httpcode = 200; $httpcode = 200;
if (!Cache::has($hash)) { if (!Cache::has($hash) || env("CACHE_ENABLED") === false) {
// Inits the Curl connection for being able to preload multiple URLs while using a keep-alive connection // Inits the Curl connection for being able to preload multiple URLs while using a keep-alive connection
$this->initCurl(); $this->initCurl();
$result = $this->getUrlContent($targetUrl, false); $result = $this->getUrlContent($targetUrl, false);
...@@ -320,6 +321,7 @@ class ProxyController extends Controller ...@@ -320,6 +321,7 @@ class ProxyController extends Controller
$data = substr($data, $header_size); $data = substr($data, $header_size);
$headerArray = []; $headerArray = [];
foreach (explode(PHP_EOL, $header) as $index => $value) { foreach (explode(PHP_EOL, $header) as $index => $value) {
if ($index > 0) { if ($index > 0) {
$ar = explode(': ', $value); $ar = explode(': ', $value);
...@@ -330,15 +332,13 @@ class ProxyController extends Controller ...@@ -330,15 +332,13 @@ class ProxyController extends Controller
$headerArray[strtolower(trim($ar[0]))] = strtolower(trim($ar[1])); $headerArray[strtolower(trim($ar[0]))] = strtolower(trim($ar[1]));
} elseif (strtolower($ar[0]) === "location") { } elseif (strtolower($ar[0]) === "location") {
$redLink = $ar[1]; $redLink = $ar[1];
if (strpos($redLink, "/") === 0) { if (strpos($redLink, "/") === 0) {
$parse = parse_url($url); $parse = parse_url($url);
$redLink = $parse["scheme"] . "://" . $parse["host"] . $redLink; $redLink = $parse["scheme"] . "://" . $parse["host"] . $redLink;
} else if (preg_match("/\w+\.\w+/si", $redLink)) { } else if (preg_match("/^\w+\.\w+$/si", $redLink)) {
$parse = parse_url($url); $parse = parse_url($url);
$redLink = $parse["scheme"] . "://" . $parse["host"] . "/" . $redLink; $redLink = $parse["scheme"] . "://" . $parse["host"] . "/" . $redLink;
} }
$headerArray[trim($ar[0])] = $this->proxifyUrl($redLink, null, false); $headerArray[trim($ar[0])] = $this->proxifyUrl($redLink, null, false);
} elseif (strtolower($ar[0]) === "content-disposition") { } elseif (strtolower($ar[0]) === "content-disposition") {
$headerArray[strtolower(trim($ar[0]))] = strtolower(trim($ar[1])); $headerArray[strtolower(trim($ar[0]))] = strtolower(trim($ar[1]));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment