Skip to content

Commit

Permalink
Encode URL properly (lobid-gnd#408)
Browse files Browse the repository at this point in the history
Question marks weren't encoded. It's better to use a library.
  • Loading branch information
dr0i committed Oct 11, 2024
1 parent e1083c9 commit 98459aa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions gatsby/lobid/static/imagesproxy.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<?php
$url = $_GET['url'];
$url=str_replace(" ", "%20", $url);
$url = implode("/", array_map("rawurlencode", explode("/", $_GET['url'])));
// restore the colon of the protocol
$positionOfColon = strpos($url,"%");
$url= substr_replace($url,":",$positionOfColon,3);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml","User-Agent: imagesproxy/0.2 (https://lobid.org/)"));

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$filename = basename($url);

Expand All @@ -27,6 +30,6 @@

header('Content-type: ' . $ctype);
echo $output = curl_exec($ch);
curl_close($ch);
curl_close($ch);
?>

0 comments on commit 98459aa

Please sign in to comment.