Skip to content

Commit

Permalink
Avoid Recursion by server hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
krysits committed Aug 11, 2020
1 parent 882cee3 commit 75aef5e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Shortener/Models/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ public function addNew()

$this->ip = $_SERVER['REMOTE_ADDR'];
$this->country = (new CountryCode($this->ip))->country_code;

if(!filter_var($this->url, FILTER_VALIDATE_URL)) return -1;

if(!filter_var($this->url, FILTER_VALIDATE_URL)) {
return -1;
}

if(parse_url($this->url,PHP_URL_HOST) === $_SERVER['SERVER_NAME']) {
return -1;
}

$this->getNextCode($this->getMaxId());

Expand Down

0 comments on commit 75aef5e

Please sign in to comment.