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

Commit 8b1ef6d

Browse files
committed
Merge pull request #29 from umbrae/fix-port
Disallow ports or non-http(s) schemes
2 parents f8b1ea8 + 42d43ee commit 8b1ef6d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

proxy.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
if (!$url || !preg_match("/^https?:/i", $url)) {
66
echo '{ "result": "Invalid URL. Please check your URL and try again.", "error": true }';
7+
return;
8+
}
9+
10+
$parsed_url = parse_url($url);
11+
$scheme = strtolower($parsed_url['scheme']);
12+
if (array_key_exists('port', $parsed_url) || ($scheme !== "http" && $scheme !== "https")) {
13+
echo '{ "result": "Invalid URL - Please check your URL and try again.", "error": true }';
14+
return;
715
}
816

917
$ch = curl_init($url);

0 commit comments

Comments
 (0)