From 700e226ba8508641fc559d1d2ddd1fd00a1eb79c Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 30 Nov 2016 18:26:40 -0500 Subject: Fix link generation when user mention is followed by a punctuation mark --- ChangeLog | 4 ++++ app/Core/Markdown.php | 2 +- tests/units/Helper/TextHelperTest.php | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 50baa140..9d79a974 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,10 @@ Breaking changes: * 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 -------------- diff --git a/app/Core/Markdown.php b/app/Core/Markdown.php index b5abe5ed..b83a3ced 100644 --- a/app/Core/Markdown.php +++ b/app/Core/Markdown.php @@ -86,7 +86,7 @@ class Markdown extends Parsedown */ 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]); if (! empty($user_id)) { diff --git a/tests/units/Helper/TextHelperTest.php b/tests/units/Helper/TextHelperTest.php index c9447abb..9b1aa94f 100644 --- a/tests/units/Helper/TextHelperTest.php +++ b/tests/units/Helper/TextHelperTest.php @@ -48,6 +48,11 @@ class TextHelperTest extends Base { $h = new TextHelper($this->container); $this->assertEquals('

Text @admin @notfound

', $h->markdown('Text @admin @notfound')); + $this->assertEquals('

Text @admin,

', $h->markdown('Text @admin,')); + $this->assertEquals('

Text @admin!

', $h->markdown('Text @admin!')); + $this->assertEquals('

Text @admin?

', $h->markdown('Text @admin? ')); + $this->assertEquals('

Text @admin.

', $h->markdown('Text @admin.')); + $this->assertEquals('

Text @admin: test

', $h->markdown('Text @admin: test')); $this->assertEquals('

Text @admin @notfound

', $h->markdown('Text @admin @notfound', true)); } -- cgit v1.2.3