From 96fb244d2ed3492d679c81f8d7a9ec5b334751f0 Mon Sep 17 00:00:00 2001 From: Sebastian Zoglowek <55794780+zoglo@users.noreply.github.com> Date: Mon, 11 Sep 2023 19:21:42 +0200 Subject: [PATCH] Fixed an issue with relative urls not working in contao 4.13 --- contao/classes/Glossary.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/contao/classes/Glossary.php b/contao/classes/Glossary.php index 4ba37a1..1f78159 100644 --- a/contao/classes/Glossary.php +++ b/contao/classes/Glossary.php @@ -69,7 +69,7 @@ public static function generateUrl(GlossaryItemModel $objItem, bool $blnAbsolute { $url = $objItem->url; - if (Validator::isRelativeUrl($url)) + if (self::isRelativeUrl($url)) { $url = Environment::get('path') . '/' . $url; } @@ -320,4 +320,17 @@ public static function transliterateAscii(string $string): string { return (string) u($string)->ascii(); } + + /** + * ToDo: Remove when Contao 4.13 support ends + * Valid relative URL + * + * @param mixed $varValue The value to be validated + * + * @return boolean True if the value is a relative URL + */ + private static function isRelativeUrl($varValue) + { + return Validator::isUrl($varValue) && !preg_match('(^([0-9a-z+.-]+:|#|/|\{\{))i', $varValue); + } }