]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fix URL mention regular expression FOR REALZ
authorMikael Nordfeldth <mmn@hethane.se>
Sat, 22 Apr 2017 09:45:24 +0000 (11:45 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sat, 22 Apr 2017 09:46:43 +0000 (11:46 +0200)
plugins/OStatus/OStatusPlugin.php

index 053615bb0695148b00266fb03a264e9bd0a941de..98d036c87dbfaebcfaa6578c5908cccc5511f497 100644 (file)
@@ -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);