From 42273401ea905161ea5a41caf536b39e8756466d Mon Sep 17 00:00:00 2001 From: umorigu Date: Thu, 5 Mar 2020 00:50:13 +0900 Subject: [PATCH] BugTrack/2505 Fix calendar_viewer Year-Month filter --- plugin/calendar_viewer.inc.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/plugin/calendar_viewer.inc.php b/plugin/calendar_viewer.inc.php index 485b934..54de62b 100644 --- a/plugin/calendar_viewer.inc.php +++ b/plugin/calendar_viewer.inc.php @@ -1,7 +1,7 @@ "; } // page name pattern - $pagepattern = strip_bracket($pagename) . '/'; + $simple_pagename = strip_bracket($pagename); if ($pagename === '') { // Support non-pagename yyyy-mm-dd pattern - $pagepattern = ''; + $pagepattern = $page_YM; + $page_datestart_idx = 0; + } else { + $pagepattern = $simple_pagename . '/' . $page_YM; + $page_datestart_idx = strlen($simple_pagename) + 1; } $pagepattern_len = strlen($pagepattern); // Get pagelist @@ -126,7 +130,7 @@ function plugin_calendar_viewer_convert() $_date = get_date('Y' . $date_sep . 'm' . $date_sep . 'd'); foreach (get_existpages() as $page) { if (strncmp($page, $pagepattern, $pagepattern_len) !== 0) continue; - $page_date = substr($page, $pagepattern_len); + $page_date = substr($page, $page_datestart_idx); // Verify the $page_date pattern (Default: yyyy-mm-dd). // Past-mode hates the future, and // Future-mode hates the past. @@ -194,8 +198,6 @@ function plugin_calendar_viewer_convert() // ここで、前後のリンクを表示 // ?plugin=calendar_viewer&file=ページ名&date=yyyy-mm - $enc_pagename = rawurlencode(substr($pagepattern, 0, $pagepattern_len - 1)); - if ($page_YM != '') { // 年月表示時 $date_sep_len = strlen($date_sep); @@ -252,7 +254,8 @@ function plugin_calendar_viewer_convert() $s_date_sep = htmlsc($date_sep); $left_link = $right_link = ''; $link = $script . '?plugin=calendar_viewer&mode=' . $mode . - '&file=' . $enc_pagename . '&date_sep=' . $s_date_sep . '&'; + '&file=' . rawurlencode($simple_pagename) . + '&date_sep=' . $s_date_sep . '&'; if ($left_YM != '') $left_link = '' . $left_text . ''; -- 2.11.0