getUrl(); } // If the URL is malformed this constraint cannot check further. catch (\InvalidArgumentException $e) { return; } // Disallow external URLs using untrusted protocols. if ($url->isExternal() && !in_array(parse_url($url->getUri(), PHP_URL_SCHEME), UrlHelper::getAllowedProtocols())) { $this->context->addViolation($constraint->message, ['@uri' => $value->uri]); } } } }