Fix URL mention regular expression FOR REALZ

This commit is contained in:
Mikael Nordfeldth 2017-04-22 11:45:24 +02:00
parent 51e5cc2ac8
commit 69e944e21a

View File

@ -284,7 +284,9 @@ class OStatusPlugin extends Plugin
static function extractUrlMentions($text) static function extractUrlMentions($text)
{ {
$wmatches = array(); $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, $text,
$wmatches, $wmatches,
PREG_OFFSET_CAPTURE); PREG_OFFSET_CAPTURE);