From ee29b23bd40fb5f3716d76667fbfe3e4452ef39e Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sat, 22 Apr 2017 11:45:24 +0200 Subject: [PATCH] Fix URL mention regular expression FOR REALZ --- plugins/OStatus/OStatusPlugin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 053615bb06..98d036c87d 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -300,7 +300,9 @@ class OStatusPlugin extends Plugin static function extractUrlMentions($text) { $wmatches = array(); - $result = preg_match_all('/(?:^|\s+)@('.URL_REGEX_DOMAIN_NAME.'(?:\/\w+)*)/', + // In the regexp below we need to match / _before_ URL_REGEX_VALID_PATH_CHARS because it otherwise gets merged + // with the TLD before (but / is in URL_REGEX_VALID_PATH_CHARS anyway, it's just its positioning that is important) + $result = preg_match_all('/(?:^|\s+)@('.URL_REGEX_DOMAIN_NAME.'(?:\/['.URL_REGEX_VALID_PATH_CHARS.']*)*)/', $text, $wmatches, PREG_OFFSET_CAPTURE); -- 2.39.5