Merge pull request #618 from ArthurHoaro/tagclean

Better whitespace handling in tags
This commit is contained in:
VirtualTam 2016-08-02 15:37:43 +02:00 committed by GitHub
commit 58f0660f80
3 changed files with 7 additions and 3 deletions

View File

@ -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;
}

View File

@ -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()
);

View File

@ -75,7 +75,7 @@ class ReferenceLinkDB
'',
1,
'20121206_182539',
'dev cartoon'
'dev cartoon tag1 tag2 tag3 tag4 '
);
}