From a4c1e32f993e0814236168e5488a5fed276ffa55 Mon Sep 17 00:00:00 2001 From: Matheus Zych Date: Tue, 17 Sep 2024 08:05:20 +0200 Subject: [PATCH] Fixes uri input throwing error when left empty but not required --- Services/Form/classes/class.ilUriInputGUI.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Services/Form/classes/class.ilUriInputGUI.php b/Services/Form/classes/class.ilUriInputGUI.php index 87af86b532c4..70dc0bcc0817 100755 --- a/Services/Form/classes/class.ilUriInputGUI.php +++ b/Services/Form/classes/class.ilUriInputGUI.php @@ -45,16 +45,19 @@ public function checkInput(): bool { $lng = $this->lng; + $uri_string = trim($this->getInput()); + // check required - if ($this->getRequired() && trim($this->str($this->getPostVar())) == "") { - $this->setAlert($lng->txt("msg_input_is_required")); - return false; + if ($uri_string === "") { + if ($this->getRequired()) { + $this->setAlert($lng->txt("msg_input_is_required")); + return false; + } + return true; } - $url = $this->getInput(); - try { - new URI($url); + new URI($uri_string); } catch (Throwable $e) { $this->setAlert($lng->txt("form_invalid_uri")); return false;