diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index b04b2a3a2..4354a8dc6 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -670,8 +670,15 @@ class WebSocketDialogMsg extends AbstractModel } $text = str_replace($matchs[0][$key], "[:{$matchChar[1]}:{$keyId}:{$matchValye[1]}:]", $text); } + // 处理链接标签 + preg_match_all("/]*?href=([\"'])(.*?)\\1[^>]*?>([^<]*?)<\/a>/is", $text, $matchs); + foreach ($matchs[2] as $key => $str) { + $herf = base64_encode($matchs[2][$key]); + $title = $matchs[3][$key] ? base64_encode($matchs[3][$key]) : $herf; + $text = str_replace($matchs[0][$key], "[:LINK:{$herf}:{$title}:]", $text); + } // 文件分享链接 - preg_match_all("/(?<=[^'\"])(https*:\/\/)((\w|=|\?|\.|\/|&|-|:|\+|%|;|#)+)/i", $text, $matchs); + preg_match_all("/(https*:\/\/)((\w|=|\?|\.|\/|&|-|:|\+|%|;|#)+)/i", $text, $matchs); if ($matchs) { foreach ($matchs[0] as $str) { preg_match("/\/single\/file\/(.*?)$/i", $str, $match); @@ -684,13 +691,6 @@ class WebSocketDialogMsg extends AbstractModel } } } - // 处理链接标签 - preg_match_all("/]*?href=([\"'])(.*?)\\1[^>]*?>([^<]*?)<\/a>/is", $text, $matchs); - foreach ($matchs[2] as $key => $str) { - $herf = $matchs[2][$key]; - $title = $matchs[3][$key] ?: $herf; - $text = str_replace($matchs[0][$key], "{$title}", $text); - } // 过滤标签 $text = strip_tags($text, '