Fixed regex to prevent false negatives

Would fail if:
- location wat written without capital letter.
- the server redirected to www.
- there was no / at the end of the url.
This commit is contained in:
TimZ99 2018-09-05 23:44:20 +02:00
parent cf6f30adfc
commit ed61b3854f
No known key found for this signature in database
GPG Key ID: 4D8268DC68E8339D
1 changed files with 9 additions and 7 deletions

View File

@ -287,13 +287,15 @@ class StatusUpdater {
// Check if the website redirects to another domain
if ($this->server['redirect_check'] == 'bad'){
$location_matches = array();
preg_match('/(Location: )(https*:\/\/)([a-zA-Z.:0-9]*)([\/][[:alnum:][:punct:]]*)/', $curl_result, $location_matches);
$ip_matches = array();
preg_match('/(https*:\/\/)([a-zA-Z.:0-9]*)([\/][[:alnum:][:punct:]]*)/', $this->server['ip'], $ip_matches);
if($location_matches[3] !== $ip_matches[2]){
$this->error = "The IP/URL redirects to another domain.";
$result = false;
}
preg_match('/([Ll]ocation: )(https*:\/\/)(www.)?([a-zA-Z.:0-9]*)([\/][[:alnum:][:punct:]]*)/', $curl_result, $location_matches);
if(!empty($location_matches)) {
$ip_matches = array();
preg_match('/(https*:\/\/)(www.)?([a-zA-Z.:0-9]*)([\/][[:alnum:][:punct:]]*)?/', $this->server['ip'], $ip_matches);
if (strtolower($location_matches[4]) !== strtolower($ip_matches[3])) {
$this->error = "The IP/URL redirects to another domain.";
$result = false;
}
}
}
// Should we check a header ?