From: Mikael Nordfeldth Date: Sat, 22 Apr 2017 09:45:24 +0000 (+0200) Subject: Fix URL mention regular expression FOR REALZ X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=69e944e21a11ce16b1e82ed94db5ec5878cad91b;p=quix0rs-gnu-social.git Fix URL mention regular expression FOR REALZ --- diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index c4322b5487..4a1d7683cc 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -284,7 +284,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);