From 4105374f95c18e0a446092e6ccec77cf84a9d4a0 Mon Sep 17 00:00:00 2001 From: umorigu Date: Tue, 12 Sep 2017 01:16:33 +0900 Subject: [PATCH] BugTrack/2213 Improve Canonical URL and reload links --- lib/func.php | 4 ++++ lib/html.php | 23 ++++++++++------------- skin/pukiwiki.skin.php | 2 +- skin/tdiary.skin.php | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/func.php b/lib/func.php index ba6ad72..f2f3270 100644 --- a/lib/func.php +++ b/lib/func.php @@ -733,6 +733,10 @@ function get_base_uri($uri_type = PKWK_URI_RELATIVE) */ function get_page_uri($page, $uri_type = PKWK_URI_RELATIVE) { + global $defaultpage; + if ($page === $defaultpage) { + return get_base_uri($uri_type); + } return get_base_uri($uri_type) . '?' . pagename_urlencode($page); } diff --git a/lib/html.php b/lib/html.php index 9f24688..5ffcd20 100644 --- a/lib/html.php +++ b/lib/html.php @@ -48,11 +48,7 @@ function catbody($title, $page, $body) $r_page = pagename_urlencode($_page); // Canonical URL - if ($_page === $defaultpage) { - $canonical_url = get_base_uri(PKWK_URI_ABSOLUTE); - } else { - $canonical_url = get_page_uri($_page, PKWK_URI_ABSOLUTE); - } + $canonical_url = get_page_uri($_page, PKWK_URI_ABSOLUTE); // Set $_LINK for skin $_LINK['add'] = "$script?cmd=add&page=$r_page"; @@ -62,20 +58,21 @@ function catbody($title, $page, $body) $_LINK['edit'] = "$script?cmd=edit&page=$r_page"; $_LINK['filelist'] = "$script?cmd=filelist"; $_LINK['freeze'] = "$script?cmd=freeze&page=$r_page"; - $_LINK['help'] = "$script?" . pagename_urlencode($help_page); + $_LINK['help'] = get_page_uri($help_page); $_LINK['list'] = "$script?cmd=list"; $_LINK['new'] = "$script?plugin=newpage&refer=$r_page"; $_LINK['rdf'] = "$script?cmd=rss&ver=1.0"; - $_LINK['recent'] = "$script?" . pagename_urlencode($whatsnew); - $_LINK['reload'] = $canonical_url; + $_LINK['recent'] = get_page_uri($whatsnew); + $_LINK['reload'] = get_page_uri($_page); $_LINK['rename'] = "$script?plugin=rename&refer=$r_page"; $_LINK['rss'] = "$script?cmd=rss"; $_LINK['rss10'] = "$script?cmd=rss&ver=1.0"; // Same as 'rdf' $_LINK['rss20'] = "$script?cmd=rss&ver=2.0"; $_LINK['search'] = "$script?cmd=search"; - $_LINK['top'] = "$script?" . pagename_urlencode($defaultpage); + $_LINK['top'] = get_page_uri($defaultpage); $_LINK['unfreeze'] = "$script?cmd=unfreeze&page=$r_page"; $_LINK['upload'] = "$script?plugin=attach&pcmd=upload&page=$r_page"; + $_LINK['canonical_url'] = $canonical_url; $login_link = "#LOGIN_ERROR"; // dummy link that is not used switch ($auth_type) { case AUTH_TYPE_FORM: @@ -375,7 +372,7 @@ $template EOD; $body .= ''; return $body; } @@ -399,13 +396,13 @@ function make_related($page, $tag = '') foreach ($links as $page=>$lastmod) { if (check_non_list($page)) continue; - $r_page = pagename_urlencode($page); + $page_uri = get_page_uri($page); $s_page = htmlsc($page); $passage = get_passage($lastmod); $_links[] = $tag ? - '' . $s_page . '' : - '' . + '' . $s_page . '' . $passage; } if (empty($_links)) return ''; // Nothing diff --git a/skin/pukiwiki.skin.php b/skin/pukiwiki.skin.php index 0d49b43..56020ab 100644 --- a/skin/pukiwiki.skin.php +++ b/skin/pukiwiki.skin.php @@ -81,7 +81,7 @@ header('Content-Type: text/html; charset=' . CONTENT_CHARSET); - + diff --git a/skin/tdiary.skin.php b/skin/tdiary.skin.php index 89c672e..fffaca7 100644 --- a/skin/tdiary.skin.php +++ b/skin/tdiary.skin.php @@ -2,7 +2,7 @@ // PukiWiki - Yet another WikiWikiWeb clone. // tdiary.skin.php // Copyright -// 2002-2016 PukiWiki Development Team +// 2002-2017 PukiWiki Development Team // 2001-2002 Originally written by yu-ji // License: GPL v2 or (at your option) any later version // @@ -651,7 +651,7 @@ function _navigator($key, $value = '', $javascript = ''){
- + -- 2.11.0