]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Domain name regular expression into lib/framework.php
authorMikael Nordfeldth <mmn@hethane.se>
Sat, 22 Apr 2017 09:07:38 +0000 (11:07 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Sat, 22 Apr 2017 09:07:38 +0000 (11:07 +0200)
lib/framework.php
plugins/OStatus/OStatusPlugin.php

index 77f2d0526a3248521c745fa63c9490265a67ae63..56a382aa65e1e2ce773fb7cb7f0db256748ee74a 100644 (file)
@@ -66,6 +66,7 @@ define('URL_REGEX_VALID_PATH_CHARS',        '\pN\pL\,\!\.\:\-\_\+\/\@\=\;\%\~\*'
 define('URL_REGEX_VALID_QSTRING_CHARS',     URL_REGEX_VALID_PATH_CHARS    . '\&');
 define('URL_REGEX_VALID_FRAGMENT_CHARS',    URL_REGEX_VALID_QSTRING_CHARS . '\?\#');
 define('URL_REGEX_EXCLUDED_END_CHARS',      '\?\.\,\!\#\:\'');  // don't include these if they are directly after a URL
+define('URL_REGEX_DOMAIN_NAME', '(?:(?!-)[A-Za-z0-9\-]{1,63}(?<!-)\.)+[A-Za-z]{2,10}');
 
 // append our extlib dir as the last-resort place to find libs
 
index 4bfd0ea23f2170b08e6ea9745a7c3cd1a96c7ef5..55a50d12c0ee2eceae17086963858a37d3f8bb26 100644 (file)
@@ -264,7 +264,7 @@ class OStatusPlugin extends Plugin
     static function extractWebfingerIds($text)
     {
         $wmatches = array();
-        $result = preg_match_all('/(?:^|\s+)@((?:\w+[\w\-\_\.]?)*(?:[\w\-\_\.]*\w+)@(?:(?!-)[A-Za-z0-9\-]{1,63}(?<!-)\.)+[A-Za-z]{2,10})/',
+        $result = preg_match_all('/(?:^|\s+)@((?:\w+[\w\-\_\.]?)*(?:[\w\-\_\.]*\w+)@'.URL_REGEX_DOMAIN_NAME.')/',
                        $text,
                        $wmatches,
                        PREG_OFFSET_CAPTURE);
@@ -284,7 +284,7 @@ class OStatusPlugin extends Plugin
     static function extractUrlMentions($text)
     {
         $wmatches = array();
-        $result = preg_match_all('!(?:^|\s+)@((?:\w+\.)*\w+(?:\w+\-\w+)*\.\w+(?:/\w+)*)!',
+        $result = preg_match_all('!(?:^|\s+)@'.URL_REGEX_DOMAIN_NAME.'(?:/\w+)*)!',
                        $text,
                        $wmatches,
                        PREG_OFFSET_CAPTURE);