diff --git a/application/LinkDB.php b/application/LinkDB.php index 929a6b0..d80434b 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -291,7 +291,7 @@ You use the community supported version of the original Shaarli project, by Seba // Remove private tags if the user is not logged in. if (! $this->_loggedIn) { - $link['tags'] = preg_replace('/(^| )\.[^($| )]+/', '', $link['tags']); + $link['tags'] = preg_replace('/(^|\s+)\.[^($|\s)]+\s*/', ' ', $link['tags']); } // Do not use the redirector for internal links (Shaarli note URL starting with a '?'). @@ -442,7 +442,7 @@ You use the community supported version of the original Shaarli project, by Seba $tags = array(); $caseMapping = array(); foreach ($this->_links as $link) { - foreach (explode(' ', $link['tags']) as $tag) { + foreach (preg_split('/\s+/', $link['tags'], 0, PREG_SPLIT_NO_EMPTY) as $tag) { if (empty($tag)) { continue; } diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php index 46956f2..3130606 100644 --- a/tests/LinkDBTest.php +++ b/tests/LinkDBTest.php @@ -317,6 +317,10 @@ class LinkDBTest extends PHPUnit_Framework_TestCase '-exclude' => 1, '.hidden' => 1, 'hashtag' => 2, + 'tag1' => 1, + 'tag2' => 1, + 'tag3' => 1, + 'tag4' => 1, ), self::$privateLinkDB->allTags() ); diff --git a/tests/utils/ReferenceLinkDB.php b/tests/utils/ReferenceLinkDB.php index fe16baa..fcc7a4f 100644 --- a/tests/utils/ReferenceLinkDB.php +++ b/tests/utils/ReferenceLinkDB.php @@ -75,7 +75,7 @@ class ReferenceLinkDB '', 1, '20121206_182539', - 'dev cartoon' + 'dev cartoon tag1 tag2 tag3 tag4 ' ); }