From 6c82a8c1b6068a2279ba30955f27217fa370edae Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Wed, 31 Jul 2024 16:30:59 +0200 Subject: [PATCH] Made url validation of less restrictive ref https://www.woltlab.com/community/thread/306975-validierung-der-url-im-urlformfield/ --- .../form/builder/field/UrlFormField.class.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/UrlFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/UrlFormField.class.php index ebd9e95802..29bbb3b7cd 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/UrlFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/UrlFormField.class.php @@ -2,9 +2,10 @@ namespace wcf\system\form\builder\field; +use Laminas\Diactoros\Exception\InvalidArgumentException; +use Laminas\Diactoros\Uri; use wcf\data\language\Language; use wcf\system\form\builder\field\validation\FormFieldValidationError; -use wcf\util\Url; /** * Implementation of a form field to enter a url. @@ -52,15 +53,19 @@ class UrlFormField extends TextFormField if ($this->isRequired() && ($this->getValue() === null || $this->getValue() === '')) { $this->addValidationError(new FormFieldValidationError('empty')); } elseif ($this->getValue() !== null && $this->getValue() !== '') { - if (!Url::is($text)) { + try { + new Uri($text); + } catch (InvalidArgumentException) { $this->addValidationError(new FormFieldValidationError( 'invalid', 'wcf.form.field.url.error.invalid', ['language' => $language] )); - } else { - parent::validateText($text, $language); + + return; } + + parent::validateText($text, $language); } } -- 2.20.1