Skip to content

Commit 4e02204

Browse files
committed
Handle missing arguments
Without this, if all arguments are missing and `HTTP_X_PROXY_URL` isn't set, the server throws an error (could happen if /proxy.php is spidered for example). This code handles that edge case. Probably could use a 400 instead of a 404 but this at least prevents the error message.
1 parent 5ab7e40 commit 4e02204

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

proxy.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,22 @@
6464
$request_params = null;
6565
}
6666
// Get URL from `csurl` in GET or POST data, before falling back to X-Proxy-URL header.
67-
$request_url = isset( $_REQUEST['csurl'] ) ? urldecode( $_REQUEST['csurl'] ) : urldecode( $_SERVER['HTTP_X_PROXY_URL'] );
67+
if ( isset( $_REQUEST['csurl'] ) ) {
68+
$request_url = urldecode( $_REQUEST['csurl'] );
69+
} else if ( isset( $_REQUEST['csurl'] ) ) {
70+
$request_url = urldecode( $_REQUEST['csurl'] );
71+
}
72+
else if ( isset( $_SERVER['HTTP_X_PROXY_URL'] ) )
73+
{
74+
$request_url = urldecode( $_SERVER['HTTP_X_PROXY_URL'] );
75+
}
76+
else
77+
{
78+
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
79+
header("Status: 404 Not Found");
80+
$_SERVER['REDIRECT_STATUS'] = 404;
81+
exit;
82+
}
6883
$p_request_url = parse_url( $request_url );
6984

7085
// csurl may exist in GET request methods

0 commit comments

Comments
 (0)