mirror of
https://github.com/friendica/friendica
synced 2025-04-25 01:10:12 +00:00
Merge pull request #10697 from MrPetovan/bug/10692-api-expand-entities
Prevent expandTags to be performed on existing links in Module\Api\Mastodon\Statuses
This commit is contained in:
commit
5246b9c4b0
3 changed files with 35 additions and 3 deletions
|
@ -2294,14 +2294,14 @@ class BBCode
|
|||
}
|
||||
|
||||
/**
|
||||
* Expand tags to URLs
|
||||
* Expand tags to URLs, checks the tag is at the start of a line or preceded by a non-word character
|
||||
*
|
||||
* @param string $body
|
||||
* @return string body with expanded tags
|
||||
*/
|
||||
public static function expandTags(string $body)
|
||||
{
|
||||
return preg_replace_callback("/([!#@])([^\^ \x0D\x0A,;:?\']*[^\^ \x0D\x0A,;:?!\'.])/",
|
||||
return preg_replace_callback("/(?<=\W|^)([!#@])([^\^ \x0D\x0A,;:?'\"]*[^\^ \x0D\x0A,;:?!'\".])/",
|
||||
function ($match) {
|
||||
switch ($match[1]) {
|
||||
case '!':
|
||||
|
@ -2314,6 +2314,7 @@ class BBCode
|
|||
}
|
||||
break;
|
||||
case '#':
|
||||
default:
|
||||
return $match[1] . '[url=' . 'https://' . DI::baseUrl() . '/search?tag=' . $match[2] . ']' . $match[2] . '[/url]';
|
||||
}
|
||||
}, $body);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue