Skip to content

Commit

Permalink
[5.2] Fix URL validator (#13700)
Browse files Browse the repository at this point in the history
Fixed #13680

Based on a Simfony patch: symfony/validator@dbac482
  • Loading branch information
billmn authored and taylorotwell committed May 25, 2016
1 parent b5b49e8 commit 6f95210
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ protected function validateUrl($attribute, $value)
\] # a IPv6 address
)
(:[0-9]+)? # a port (optional)
(/?|/\S+) # a /, nothing or a / with something
(/?|/\S+|\?\S*|\#\S*) # a /, nothing, a / with something, a query or a fragment
$~ixu';

return preg_match($pattern, $value) === 1;
Expand Down
8 changes: 6 additions & 2 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,12 @@ public function validUrls()
['http://президент.рф/'],
['http://스타벅스코리아.com'],
['http://xn--d1abbgf6aiiy.xn--p1ai/'],
['http://laravel.com?'],
['http://laravel.com?q=1'],
['http://laravel.com/?q=1'],
['http://laravel.com#'],
['http://laravel.com#fragment'],
['http://laravel.com/#fragment'],
];
}

Expand All @@ -1591,8 +1597,6 @@ public function invalidUrls()
['http://goog_le.com'],
['http://google.com::aa'],
['http://google.com:aa'],
['http://laravel.com?'],
['http://laravel.com#'],
['http://127.0.0.1:aa'],
['http://[::1'],
['foo://bar'],
Expand Down

0 comments on commit 6f95210

Please sign in to comment.