[TikiWiki-commits] [Git][tikiwiki/tiki][tiki-fix-tracker-url-wikisyntax] [ENH] Url.php: add validation for wiki link syntax in URL fields
"Sammy Ndabo \(@ndabosam084\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <6989e7859940f_3b5d4c9e8101976@gitlab-sidekiq-low-urgency-cpu-bound-v2-65bcbb5696-4848m.mail> |
Sammy Ndabo pushed to branch tiki-fix-tracker-url-wikisyntax at Tiki Wiki CMS Groupware / Tiki
Commits:
0ade9a15 by Sammy Ndabo at 2026-02-09T15:55:05+02:00
[ENH] Url.php: add validation for wiki link syntax in URL fields
- - - - -
1 changed file:
- lib/core/Tracker/Field/Url.php
Changes:
=====================================
lib/core/Tracker/Field/Url.php
=====================================
@@ -130,6 +130,35 @@ class Tracker_Field_Url extends \Tracker\Field\AbstractItemField implements \Tra
|| (str_starts_with($value, '[') && str_ends_with($value, ']'));
}
+ public function isValid($ins_fields_data)
+ {
+ $fieldId = $this->getFieldId();
+ $value = $ins_fields_data[$fieldId]['value'] ?? $this->getValue();
+ $trimmed = trim((string) $value);
+
+ if (self::hasBrokenWikiSyntaxWrapper($trimmed)) {
+ return tr('Invalid wiki link syntax. Use complete wrappers like ((PageName)) or [url|text].');
+ }
+
+ return true;
+ }
+
+ // Syntax check is limited to detecting [ without ] or (( without )), to allow wiki links but avoid complex syntax that could break the URL field rendering. But we should inherit from Tracker_Field_Text if we wanted full wiki syntax support, to get consistent parsing and escaping behavior.
+ protected static function hasBrokenWikiSyntaxWrapper(string $value): bool
+ {
+ if ($value === '') {
+ return false;
+ }
+
+ $startsDoubleParens = str_starts_with($value, '((');
+ $endsDoubleParens = str_ends_with($value, '))');
+ $startsBracket = str_starts_with($value, '[');
+ $endsBracket = str_ends_with($value, ']');
+
+ return ($startsDoubleParens xor $endsDoubleParens)
+ || ($startsBracket xor $endsBracket);
+ }
+
public function renderInput($context = [])
{
return $this->renderTemplate("trackerinput/url.tpl", $context);
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/0ade9a15e0ee16ed0b37e9fd37d66e9e1d28f88b
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/0ade9a15e0ee16ed0b37e9fd37d66e9e1d28f88b
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