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