diff --git a/application/LinkDB.php b/application/LinkDB.php index e9d216ea..d80434bf 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -291,7 +291,7 @@ private function _readDB() // Remove private tags if the user is not logged in. if (! $this->_loggedIn) { - $link['tags'] = preg_replace('/(^|\s*)\.[^($| )]+\s*$/', '', $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 '?'). diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php index e413928a..31306069 100644 --- a/tests/LinkDBTest.php +++ b/tests/LinkDBTest.php @@ -317,6 +317,10 @@ public function testAllTags() '-exclude' => 1, '.hidden' => 1, 'hashtag' => 2, + 'tag1' => 1, + 'tag2' => 1, + 'tag3' => 1, + 'tag4' => 1, ), self::$privateLinkDB->allTags() ); @@ -429,30 +433,4 @@ public function testFilterHashInValid() { self::$publicLinkDB->filterHash(''); } - - /** - * test whitespace handling in tags. - * split on whitespace runs and don't allow empty tags. - */ - public function testReadTagsWithWhitespace() - { - // test load contains "tags": " tag1 tag2 tag3 tag4 " - $ds = ''; - file_put_contents(self::$testDatastore, $ds); - self::$publicLinkDB = new LinkDB(self::$testDatastore, false, false); - - $this->assertEquals( - array( - 'tag1' => 1, - 'tag2' => 1, - 'tag3' => 1, - 'tag4' => 1 - ), - self::$publicLinkDB->allTags() - ); - } } diff --git a/tests/utils/ReferenceLinkDB.php b/tests/utils/ReferenceLinkDB.php index fe16baac..fcc7a4f9 100644 --- a/tests/utils/ReferenceLinkDB.php +++ b/tests/utils/ReferenceLinkDB.php @@ -75,7 +75,7 @@ function __construct() '', 1, '20121206_182539', - 'dev cartoon' + 'dev cartoon tag1 tag2 tag3 tag4 ' ); }