Skip to content

Commit 3ff0a93

Browse files
authored
getTagLinkUrlで取得するタグの名称をurlエンコード
1 parent ceed85c commit 3ff0a93

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

lib/Baser/Plugin/Blog/Test/Case/View/Helper/BlogHelperTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,10 @@ public function testTagList($expected, $name, $options = [])
804804
public function tagListDataProvider()
805805
{
806806
return [
807-
['/(?=\/tag\/タグ1).*?(?!.*\/tag\/タグ2).*?(?!.*\/tag\/タグ3)/s', 'blog1'],
808-
['/(?=\/tag\/タグ1).*?(?=\/tag\/タグ2).*?(?=\/tag\/タグ3)/s', '/s/blog3/'],
809-
['/(?=\/tags\/タグ1).*?(?=\/tags\/タグ2).*?(?=\/tags\/タグ3).*?(?=\/tags\/タグ4).*?(?=\/tags\/タグ5)/s', null],
810-
['/(?=\/tag\/タグ1).*?\(2\)/s', 'blog1', ['postCount' => true]],
807+
['/(?=\/tag\/%E3%82%BF%E3%82%B0%EF%BC%91).*?(?!.*\/tag\/%E3%82%BF%E3%82%B0%EF%BC%92).*?(?!.*\/tag\/%E3%82%BF%E3%82%B0%EF%BC%93)/s', 'blog1'],
808+
['/(?=\/tag\/%E3%82%BF%E3%82%B0%EF%BC%91).*?(?=\/tag\/%E3%82%BF%E3%82%B0%EF%BC%92).*?(?=\/tag\/%E3%82%BF%E3%82%B0%EF%BC%93)/s', '/s/blog3/'],
809+
['/(?=\/tags\/%E3%82%BF%E3%82%B0%EF%BC%91).*?(?=\/tags\/%E3%82%BF%E3%82%B0%EF%BC%92).*?(?=\/tags\/%E3%82%BF%E3%82%B0%EF%BC%93).*?(?=\/tags\/%E3%82%BF%E3%82%B0%EF%BC%94).*?(?=\/tags\/%E3%82%BF%E3%82%B0%EF%BC%95)/s', null],
810+
['/(?=\/tag\/%E3%82%BF%E3%82%B0%EF%BC%91).*?\(2\)/s', 'blog1', ['postCount' => true]],
811811
];
812812
}
813813

@@ -836,13 +836,13 @@ public function testGetTagLinkUrl($currentUrl, $blogContentId, $name, $base, $us
836836
public function getTagLinkUrlDataProvider()
837837
{
838838
return [
839-
['/', 1, 'タグ1', '', false, '/news/archives/tag/タグ1'],
840-
['/', 1, 'タグ1', '/sub', false, '/news/archives/tag/タグ1'],
841-
['/', 1, 'タグ1', '/sub', true, '/sub/news/archives/tag/タグ1'],
842-
['/en/', 3, 'タグ2', '', false, '/en/news/archives/tag/タグ2'],
843-
['/', 4, 'タグ2', '', false, 'http://sub.main.com/news/archives/tag/タグ2'],
844-
['/', null, 'タグ1', '', false, '/tags/タグ1'],
845-
['/s/', null, 'タグ2', '', false, '/s/tags/タグ2']
839+
['/', 1, 'タグ1', '', false, '/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%91'],
840+
['/', 1, 'タグ1', '/sub', false, '/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%91'],
841+
['/', 1, 'タグ1', '/sub', true, '/sub/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%91'],
842+
['/en/', 3, 'タグ2', '', false, '/en/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%92'],
843+
['/', 4, 'タグ2', '', false, 'http://sub.main.com/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%92'],
844+
['/', null, 'タグ1', '', false, '/tags/%E3%82%BF%E3%82%B0%EF%BC%91'],
845+
['/s/', null, 'タグ2', '', false, '/s/tags/%E3%82%BF%E3%82%B0%EF%BC%92']
846846
];
847847
}
848848

@@ -871,10 +871,10 @@ public function testGetTagLink($expected, $currentUrl, $blogContentId, $name)
871871
public function getTagLinkDataProvider()
872872
{
873873
return [
874-
['<a href="/news/archives/tag/タグ1">タグ1</a>', '/', 1, 'タグ1'],
875-
['<a href="/s/blog3/archives/tag/タグ2">タグ2</a>', '/s/', 3, 'タグ2'],
876-
['<a href="/tags/タグ1">タグ1</a>', '/', null, 'タグ1'],
877-
['<a href="/s/tags/タグ2">タグ2</a>', '/s/', null, 'タグ2']
874+
['<a href="/news/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%91">タグ1</a>', '/', 1, 'タグ1'],
875+
['<a href="/s/blog3/archives/tag/%E3%82%BF%E3%82%B0%EF%BC%92">タグ2</a>', '/s/', 3, 'タグ2'],
876+
['<a href="/tags/%E3%82%BF%E3%82%B0%EF%BC%91">タグ1</a>', '/', null, 'タグ1'],
877+
['<a href="/s/tags/%E3%82%BF%E3%82%B0%EF%BC%92">タグ2</a>', '/s/', null, 'タグ2']
878878
];
879879
}
880880

lib/Baser/Plugin/Blog/View/Helper/BlogHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,11 +1452,11 @@ public function getTagLinkUrl($blogContentId, $tag, $base = true)
14521452
if (!empty($this->content['url'])) {
14531453
$site = BcSite::findByUrl($this->content['url']);
14541454
$url = $this->BcBaser->getContentsUrl($this->content['url'], !$this->isSameSiteBlogContent($blogContentId), !empty($site->useSubDomain), false);
1455-
$url = $url . 'archives/tag/' . $tag['name'];
1455+
$url = $url . 'archives/tag/' . rawurlencode($tag['name']);
14561456
}
14571457
}
14581458
if (!$url) {
1459-
$url = '/tags/' . $tag['name'];
1459+
$url = '/tags/' . rawurlencode($tag['name']);
14601460
$site = BcSite::findCurrent(true);
14611461
if ($site && $site->alias && !$site->useSubDomain) {
14621462
$url = '/' . $site->alias . $url;

0 commit comments

Comments
 (0)