From 310875a689c64a940b58e65df15bc08f67cd6ba6 Mon Sep 17 00:00:00 2001 From: Rushaway Date: Wed, 16 Sep 2026 23:50:50 +0200 Subject: [PATCH] fix(comments): stop hyperlinks truncating at hyphens The auto-linkify regex for comment URLs used [\w/_\.]* for the path segment, which excludes '-'. A link like https://youtu.be/T1MnG-gKgF0 was rendered as a clickable https://youtu.be/T1MnG followed by plain-text -gKgF0. Added '-' to the path character class in all three places this regex is duplicated. Co-Authored-By: Claude Sonnet 5 --- web/pages/admin.bans.php | 2 +- web/pages/page.banlist.php | 2 +- web/pages/page.commslist.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/pages/admin.bans.php b/web/pages/admin.bans.php index fe65e4220..017d75f66 100644 --- a/web/pages/admin.bans.php +++ b/web/pages/admin.bans.php @@ -1346,7 +1346,7 @@ function bansBuildComments(array $commentres, $userbank, int $rowId, string $typ $cdata['added'] = Config::time($crow['added']); $commentText = html_entity_decode($crow['commenttxt'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); $commentText = encodePreservingBr($commentText); - $commentText = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '$1', $commentText); + $commentText = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.-]*(\?\S+)?)?)?)@', '$1', $commentText); $cdata['commenttxt'] = $commentText; if (!empty($crow['edittime'])) { diff --git a/web/pages/page.banlist.php b/web/pages/page.banlist.php index 0a1ae0bc0..681722c65 100644 --- a/web/pages/page.banlist.php +++ b/web/pages/page.banlist.php @@ -1123,7 +1123,7 @@ function setPostKey() $commentText = html_entity_decode($crow['commenttxt'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); $commentText = encodePreservingBr($commentText); // Parse links and wrap them in a tag to be easily clickable - $commentText = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '$1', $commentText); + $commentText = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.-]*(\?\S+)?)?)?)@', '$1', $commentText); $cdata['commenttxt'] = $commentText; if (!empty($crow['edittime'])) { diff --git a/web/pages/page.commslist.php b/web/pages/page.commslist.php index 6c97490be..361eb1128 100644 --- a/web/pages/page.commslist.php +++ b/web/pages/page.commslist.php @@ -902,7 +902,7 @@ function setPostKey() $commentText = html_entity_decode($crow['commenttxt'], ENT_QUOTES | ENT_HTML5, 'UTF-8'); $commentText = encodePreservingBr($commentText); // Parse links and wrap them in a tag to be easily clickable - $commentText = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', '$1', $commentText); + $commentText = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.-]*(\?\S+)?)?)?)@', '$1', $commentText); $cdata['commenttxt'] = $commentText; if (!empty($crow['edittime'])) {