Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Stricter URL checking in JSON fetcher
Browse files Browse the repository at this point in the history
  • Loading branch information
umbrae committed Jun 14, 2011
1 parent c628477 commit 779a6fd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion proxy.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php

$url = filter_var($_POST['url'], FILTER_VALIDATE_URL);
$url = filter_var($_POST['url'], FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED);

if (!$url || !preg_match("/^https?:/i", $url)) {
echo '{ "result": "Invalid URL. Please check your URL and try again.", "error": true }';
}

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
Expand Down

0 comments on commit 779a6fd

Please sign in to comment.