fixed wrongly parsing link with @ symbol as username

This commit is contained in:
Tony Yang
2019-06-29 23:57:44 +08:00
parent 787c58906e
commit ef220fe537
2 changed files with 6 additions and 2 deletions

View File

@@ -9,10 +9,12 @@ function parse_user_tag($markdown) {
$regex = array(
"code_block" => "/(`{1,3}[^`]*`{1,3})/",
"email" => "/[^@\s]*@[^@\s]*\.[^@\s]*/",
"url" => "/https?\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]+(\/\S*)/",
"username" => "/@(\w+)/"
);
$tmp = preg_replace($regex["code_block"], " ", $markdown);
$tmp = preg_replace($regex['url'], " ", $tmp);
$tmp = preg_replace($regex["email"], " ", $tmp);
preg_match_all($regex["username"], $tmp, $username_list);