FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge pull request #11246 from cviebrock/fix-active-url-validation · JavaDevl/framework@8a65b70 · GitHub

Commit 8a65b70

Browse files
committed
Merge pull request laravel#11246 from cviebrock/fix-active-url-validation
[5.1] Fix active url validation
2 parents 4f15d8c + 7a2f7c7 commit 8a65b70

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎src/Illuminate/Validation/Validator.php‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,9 +1235,11 @@ protected function validateUrl($attribute, $value)
12351235
*/
12361236
protected function validateActiveUrl($attribute, $value)
12371237
{
1238-
$url = str_replace(['http://', 'https://', 'ftp://'], '', strtolower($value));
1238+
if ($url = parse_url($value, PHP_URL_HOST)) {
1239+
return count(dns_get_record($url, DNS_A | DNS_AAAA)) > 0;
1240+
}
12391241

1240-
return checkdnsrr($url, 'A');
1242+
return false;
12411243
}
12421244

12431245
/**

‎tests/Validation/ValidationValidatorTest.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,9 @@ public function testValidateActiveUrl()
10981098

10991099
$v = new Validator($trans, ['x' => 'http://www.google.com'], ['x' => 'active_url']);
11001100
$this->assertTrue($v->passes());
1101+
1102+
$v = new Validator($trans, ['x' => 'http://www.google.com/about'], ['x' => 'active_url']);
1103+
$this->assertTrue($v->passes());
11011104
}
11021105

11031106
public function testValidateImage()

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL