![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/framework/Url/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\Url; use Laminas\Validator\AbstractValidator; use Laminas\Validator\Uri; /** * URL validator */ class Validator extends AbstractValidator { /**#@+ * Error keys */ public const INVALID_URL = 'uriInvalid'; /**#@-*/ /** * @var Uri */ private $validator; /** * @param Uri $validator */ public function __construct(Uri $validator) { parent::__construct(); // set translated message template $this->setMessage((string)new \Magento\Framework\Phrase("Invalid URL '%value%'."), Uri::INVALID); $this->validator = $validator; $this->validator->setAllowRelative(false); } /** * Validation failure message template definitions * * @var array */ protected $messageTemplates = [Uri::INVALID => "Invalid URL '%value%'."]; /** * Validate value * * @param string $value * @return bool */ public function isValid($value) { $this->setValue($value); $valid = $this->validator->isValid($value); // phpcs:ignore Magento2.Functions.DiscouragedFunction $protocol = parse_url($value ? $value : '', PHP_URL_SCHEME); if ($valid && ($protocol === 'https' || $protocol === 'http')) { return true; } $this->error(Uri::INVALID); return false; } }