Don't match @nickname on @nickname@server.com
This commit is contained in:
parent
cb40f72c7e
commit
36f099958c
@ -858,7 +858,8 @@ function common_find_mentions_raw($text)
|
|||||||
PREG_OFFSET_CAPTURE);
|
PREG_OFFSET_CAPTURE);
|
||||||
|
|
||||||
$atmatches = array();
|
$atmatches = array();
|
||||||
preg_match_all('/(?:^|\s+)@(' . Nickname::DISPLAY_FMT . ')\b/',
|
// the regexp's "(?!\@)" makes sure it doesn't matches the single "@remote" in "@remote@server.com"
|
||||||
|
preg_match_all('/(?:^|\s+)@(' . Nickname::DISPLAY_FMT . ')\b(?!\@)/',
|
||||||
$text,
|
$text,
|
||||||
$atmatches,
|
$atmatches,
|
||||||
PREG_OFFSET_CAPTURE);
|
PREG_OFFSET_CAPTURE);
|
||||||
|
@ -285,8 +285,8 @@ class OStatusPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
$matches = array();
|
$matches = array();
|
||||||
|
|
||||||
// Webfinger matches: @user@example.com
|
// Webfinger matches: @user@example.com or even @user--one.george_orwell@1984.biz
|
||||||
if (preg_match_all('!(?:^|\s+)@((?:\w+\.)*\w+@(?:\w+\-?\w+\.)*\w+(?:\w+\-\w+)*\.\w+)!',
|
if (preg_match_all('!(?:^|\s+)@((?:\w+[\w\-\_\.]?)*(?:[\w\-\_\.]*\w+)@(?:\w+\-?\w+\.)*\w+(?:\w+\-\w+)*\.\w+)!',
|
||||||
$text,
|
$text,
|
||||||
$wmatches,
|
$wmatches,
|
||||||
PREG_OFFSET_CAPTURE)) {
|
PREG_OFFSET_CAPTURE)) {
|
||||||
@ -299,12 +299,16 @@ class OStatusPlugin extends Plugin
|
|||||||
$profile = $oprofile->localProfile();
|
$profile = $oprofile->localProfile();
|
||||||
$text = !empty($profile->nickname) && mb_strlen($profile->nickname) < mb_strlen($target) ?
|
$text = !empty($profile->nickname) && mb_strlen($profile->nickname) < mb_strlen($target) ?
|
||||||
$profile->nickname : $target;
|
$profile->nickname : $target;
|
||||||
|
$url = $profile->getUri();
|
||||||
|
if (!common_valid_http_url($url)) {
|
||||||
|
$url = $profile->getUrl();
|
||||||
|
}
|
||||||
$matches[$pos] = array('mentioned' => array($profile),
|
$matches[$pos] = array('mentioned' => array($profile),
|
||||||
'type' => 'mention',
|
'type' => 'mention',
|
||||||
'text' => $text,
|
'text' => $text,
|
||||||
'position' => $pos,
|
'position' => $pos,
|
||||||
'length' => mb_strlen($target),
|
'length' => mb_strlen($target),
|
||||||
'url' => $profile->getUrl());
|
'url' => $url);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log(LOG_ERR, "Webfinger check failed: " . $e->getMessage());
|
$this->log(LOG_ERR, "Webfinger check failed: " . $e->getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user