[TikiWiki-commits] [Git][tikiwiki/tiki][tiki-fix-tracker-url-wikisyntax] [ENH] trackerFieldUrl: document limited wiki-syntax handling in tracker field...

"Sammy Ndabo \(@ndabosam084\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6989c9316506a_3beddcbc75832@gitlab-sidekiq-low-urgency-cpu-bound-v2-65bcbb5696-ntjtz.mail>

Sammy Ndabo pushed to branch tiki-fix-tracker-url-wikisyntax at Tiki Wiki CMS Groupware / Tiki


Commits:
beb6bf7b by Sammy Ndabo at 2026-02-09T13:46:07+02:00
[ENH] trackerFieldUrl: document limited wiki-syntax handling in tracker field URL field and add unit tests

- - - - -


3 changed files:

- lib/core/Tracker/Field/Url.php
- lib/parser/parserlib.php
- + lib/test/Core/Tracker/Field/UrlTest.php


Changes:

=====================================
lib/core/Tracker/Field/Url.php
=====================================
@@ -79,11 +79,11 @@ class Tracker_Field_Url extends \Tracker\Field\AbstractItemField implements \Tra
 
         if (empty($url) || $context['list_mode'] == 'csv' || $this->getOption('linkToURL') == 1) {
             return $url;
-        } elseif (
-            (str_starts_with($trimmed, '((') && str_ends_with($trimmed, '))'))
-            || (str_starts_with($trimmed, '[') && str_ends_with($trimmed, ']'))
-        ) {
-            // Allow wiki link syntax in URL fields (e.g. ((PageName)) or [url|text]).
+        } elseif (self::isWikiSyntaxLink($trimmed)) {
+            // Intentionally limited wiki-syntax detection for URL fields.
+            // Supports only full-value wrappers like ((PageName)) or [url|text].
+            // TODO: For full wiki parsing consistency (escaping, multilingual behavior, shared parsing path),
+            // consider refactoring URL to inherit Tracker_Field_Text in a separate, non-backport change.
             return TikiLib::lib('parser')->parse_data_simple($url);
         } elseif ($this->getOption('linkToURL') == 2) { // Site title as link
             return smarty_function_object_link(
@@ -124,6 +124,12 @@ class Tracker_Field_Url extends \Tracker\Field\AbstractItemField implements \Tra
         }
     }
 
+    protected static function isWikiSyntaxLink(string $value): bool
+    {
+        return (str_starts_with($value, '((') && str_ends_with($value, '))'))
+            || (str_starts_with($value, '[') && str_ends_with($value, ']'));
+    }
+
     public function renderInput($context = [])
     {
         return $this->renderTemplate("trackerinput/url.tpl", $context);


=====================================
lib/parser/parserlib.php
=====================================
@@ -1595,6 +1595,8 @@ class ParserLib extends TikiDb_Bridge
 
     /** Simpler and faster parse than parse_data()
      * This is only called from the parse Smarty modifier, for preference definitions.
+     * Also called in Url.php when parsing the title of a page, to allow wikilinks in titles, but without
+     * allowing plugins or other complex syntax.
      */
     public function parse_data_simple($data)
     {


=====================================
lib/test/Core/Tracker/Field/UrlTest.php
=====================================
@@ -0,0 +1,56 @@
+<?php
+
+// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
+//
+// All Rights Reserved. See copyright.txt for details and a complete list of authors.
+// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
+
+namespace TikiTests;
+
+class TrackerFieldUrlTest extends \PHPUnit\Framework\TestCase
+{
+    /**
+     * @dataProvider supportedWikiSyntaxProvider
+     */
+    public function testIsWikiSyntaxLinkSupportedInputs(string $value): void
+    {
+        $this->assertTrue($this->invokeIsWikiSyntaxLink(trim($value)));
+    }
+
+    /**
+     * @dataProvider unsupportedWikiSyntaxProvider
+     */
+    public function testIsWikiSyntaxLinkUnsupportedInputs(string $value): void
+    {
+        $this->assertFalse($this->invokeIsWikiSyntaxLink(trim($value)));
+    }
+
+    public static function supportedWikiSyntaxProvider(): array
+    {
+        return [
+            'wikilink' => ['((PageName))'],
+            'wikilink with spaces around input' => ['  ((PageName))  '],
+            'external link with label' => ['[https://example.org|Example]'],
+            'external link with spaces around input' => ['  [https://example.org|Example]  '],
+        ];
+    }
+
+    public static function unsupportedWikiSyntaxProvider(): array
+    {
+        return [
+            'plain url' => ['https://example.org'],
+            'broken wikilink prefix only' => ['((PageName'],
+            'broken bracket syntax suffix only' => ['https://example.org|Example]'],
+            'escaped bracket syntax is out of scope' => ['\[https://example.org|Example]'],
+            'mixed content around syntax is out of scope' => ['prefix ((PageName)) suffix'],
+        ];
+    }
+
+    private function invokeIsWikiSyntaxLink(string $value): bool
+    {
+        $method = new \ReflectionMethod(\Tracker_Field_Url::class, 'isWikiSyntaxLink');
+        $method->setAccessible(true);
+
+        return (bool) $method->invoke(null, $value);
+    }
+}



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/beb6bf7b3084bb1285a467f7d10e641be4ae5d88

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/beb6bf7b3084bb1285a467f7d10e641be4ae5d88
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.