Merge pull request #618 from ArthurHoaro/tagclean
Better whitespace handling in tags
This commit is contained in:
commit
58f0660f80
3 changed files with 7 additions and 3 deletions
|
@ -291,7 +291,7 @@ private function _readDB()
|
||||||
|
|
||||||
// Remove private tags if the user is not logged in.
|
// Remove private tags if the user is not logged in.
|
||||||
if (! $this->_loggedIn) {
|
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 '?').
|
// Do not use the redirector for internal links (Shaarli note URL starting with a '?').
|
||||||
|
@ -442,7 +442,7 @@ public function allTags()
|
||||||
$tags = array();
|
$tags = array();
|
||||||
$caseMapping = array();
|
$caseMapping = array();
|
||||||
foreach ($this->_links as $link) {
|
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)) {
|
if (empty($tag)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,6 +317,10 @@ public function testAllTags()
|
||||||
'-exclude' => 1,
|
'-exclude' => 1,
|
||||||
'.hidden' => 1,
|
'.hidden' => 1,
|
||||||
'hashtag' => 2,
|
'hashtag' => 2,
|
||||||
|
'tag1' => 1,
|
||||||
|
'tag2' => 1,
|
||||||
|
'tag3' => 1,
|
||||||
|
'tag4' => 1,
|
||||||
),
|
),
|
||||||
self::$privateLinkDB->allTags()
|
self::$privateLinkDB->allTags()
|
||||||
);
|
);
|
||||||
|
|
|
@ -75,7 +75,7 @@ function __construct()
|
||||||
'',
|
'',
|
||||||
1,
|
1,
|
||||||
'20121206_182539',
|
'20121206_182539',
|
||||||
'dev cartoon'
|
'dev cartoon tag1 tag2 tag3 tag4 '
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue