Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify hostname check to not fail on over 26 chars. #140

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/URI.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class URI

const PATH_REGEX = '/^(?:(%[0-9a-f]{2})|[a-z0-9\/:@\-._~\!\$&\'\(\)*+,;=])*$/i';

const HOSTNAME_REGEX = '/^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9]){1,63}\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9]){1,63}$/i';

const TEMPLATE_VARSPEC_REGEX = '~^(?<varname>[a-zA-Z0-9\_\%\.]+)(?:(?<explode>\*)?|\:(?<prefix>\d+))?$~';

const TEMPLATE_REGEX = <<<'REGEX'
Expand Down Expand Up @@ -151,7 +149,7 @@ public static function isValid(string $uri, bool $require_scheme = true): bool
*/
public static function isValidHostname(string $host): bool
{
if (preg_match( static::HOSTNAME_REGEX, $host)) {
if (filter_var($host, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
return true;
}
if (preg_match('/^\[(?<ip>[^\]]+)\]$/', $host, $m)) {
Expand Down