Fix link generation when user mention is followed by a punctuation mark
This commit is contained in:
@@ -10,6 +10,10 @@ Breaking changes:
|
|||||||
|
|
||||||
* Rename command line tool `./kanboard` to `./cli`
|
* Rename command line tool `./kanboard` to `./cli`
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
* Fix link generation when user mention is followed by a punctuation mark
|
||||||
|
|
||||||
Version 1.0.34
|
Version 1.0.34
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class Markdown extends Parsedown
|
|||||||
*/
|
*/
|
||||||
protected function inlineUserLink(array $Excerpt)
|
protected function inlineUserLink(array $Excerpt)
|
||||||
{
|
{
|
||||||
if (! $this->isPublicLink && preg_match('/^@([^\s]+)/', $Excerpt['text'], $matches)) {
|
if (! $this->isPublicLink && preg_match('/^@([^\s,!.:?]+)/', $Excerpt['text'], $matches)) {
|
||||||
$user_id = $this->container['userModel']->getIdByUsername($matches[1]);
|
$user_id = $this->container['userModel']->getIdByUsername($matches[1]);
|
||||||
|
|
||||||
if (! empty($user_id)) {
|
if (! empty($user_id)) {
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ class TextHelperTest extends Base
|
|||||||
{
|
{
|
||||||
$h = new TextHelper($this->container);
|
$h = new TextHelper($this->container);
|
||||||
$this->assertEquals('<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link">@admin</a> @notfound</p>', $h->markdown('Text @admin @notfound'));
|
$this->assertEquals('<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link">@admin</a> @notfound</p>', $h->markdown('Text @admin @notfound'));
|
||||||
|
$this->assertEquals('<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link">@admin</a>,</p>', $h->markdown('Text @admin,'));
|
||||||
|
$this->assertEquals('<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link">@admin</a>!</p>', $h->markdown('Text @admin!'));
|
||||||
|
$this->assertEquals('<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link">@admin</a>? </p>', $h->markdown('Text @admin? '));
|
||||||
|
$this->assertEquals('<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link">@admin</a>.</p>', $h->markdown('Text @admin.'));
|
||||||
|
$this->assertEquals('<p>Text <a href="?controller=UserViewController&action=profile&user_id=1" class="user-mention-link">@admin</a>: test</p>', $h->markdown('Text @admin: test'));
|
||||||
$this->assertEquals('<p>Text @admin @notfound</p>', $h->markdown('Text @admin @notfound', true));
|
$this->assertEquals('<p>Text @admin @notfound</p>', $h->markdown('Text @admin @notfound', true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user