• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョン75279a82c775637ed854b799d259d4014f39497b (tree)
日時2021-11-28 20:18:18
作者umorigu <umorigu@gmai...>
コミッターumorigu

ログメッセージ

BugTrack/2525 Page-URI customize mechanism

Introduce PukiWikiStandardPageURIHandler class

* URI fragment: '?' + pagename_encode($Page)

変更サマリ

差分

--- a/lib/func.php
+++ b/lib/func.php
@@ -524,20 +524,17 @@ function page_list($pages, $cmd = 'read', $withfilename = FALSE)
524524 mb_regex_encoding(SOURCE_ENCODING);
525525 $readings = get_readings($pages);
526526 }
527-
528527 $list = $matches = array();
529-
530- // Shrink URI for read
531- if ($cmd == 'read') {
532- $href = $script . '?';
533- } else {
534- $href = $script . '?cmd=' . $cmd . '&amp;page=';
535- }
536528 uasort($pages, 'strnatcmp');
537529 foreach($pages as $file=>$page) {
538- $r_page = pagename_urlencode($page);
539530 $s_page = htmlsc($page, ENT_QUOTES);
540- $str = ' <li><a href="' . $href . $r_page . '">' .
531+ // Shrink URI for read
532+ if ($cmd == 'read') {
533+ $href = get_page_uri($page);
534+ } else {
535+ $href = $script . '?cmd=' . $cmd . '&amp;page=' . rawurlencode($page);
536+ }
537+ $str = ' <li><a href="' . $href . '">' .
541538 $s_page . '</a> ' . get_pg_passage($page);
542539 if ($withfilename) {
543540 $s_file = htmlsc($file);
@@ -861,11 +858,11 @@ function get_base_uri($uri_type = PKWK_URI_RELATIVE)
861858 */
862859 function get_page_uri($page, $uri_type = PKWK_URI_RELATIVE)
863860 {
864- global $defaultpage;
861+ global $defaultpage, $pkwk_page_uri_handler;
865862 if ($page === $defaultpage) {
866863 return get_base_uri($uri_type);
867864 }
868- return get_base_uri($uri_type) . '?' . pagename_urlencode($page);
865+ return get_base_uri($uri_type) . $pkwk_page_uri_handler->get_page_uri_fragment($page);
869866 }
870867
871868 // Get absolute-URI of this script
@@ -1180,6 +1177,28 @@ function get_preg_u() {
11801177 return $utf8u;
11811178 }
11821179
1180+class PukiWikiStandardPageURIHandler {
1181+ function get_page_uri_fragment($page) {
1182+ return '?' . pagename_urlencode($page);
1183+ }
1184+
1185+ function get_page_from_query_string($query_string) {
1186+ $arg = $query_string;
1187+ $arg = preg_replace("#^([^&]*)&.*$#", "$1", $arg);
1188+ if ($arg == '') {
1189+ return null;
1190+ }
1191+ if (strpos($arg, '=') !== false) {
1192+ // Found '/?key=value'
1193+ return null;
1194+ }
1195+ $arg = urldecode($arg);
1196+ $arg = strip_bracket($arg);
1197+ $arg = input_filter($arg);
1198+ return $arg;
1199+ }
1200+}
1201+
11831202 //// Compat ////
11841203
11851204 // is_a -- Returns TRUE if the object is of this class or has this class as one of its parents
--- a/lib/init.php
+++ b/lib/init.php
@@ -398,13 +398,10 @@ if (isset($get['md5']) && $get['md5'] != '' &&
398398 if (! isset($vars['cmd']) && ! isset($vars['plugin'])) {
399399
400400 $get['cmd'] = $post['cmd'] = $vars['cmd'] = 'read';
401-
402- $arg = preg_replace("#^([^&]*)&.*$#", "$1", $arg);
403- if ($arg == '') $arg = $defaultpage;
404- if (strpos($arg, '=') !== false) $arg = $defaultpage; // Found '/?key=value'
405- $arg = urldecode($arg);
406- $arg = strip_bracket($arg);
407- $arg = input_filter($arg);
401+ $arg = $pkwk_page_uri_handler->get_page_from_query_string($arg);
402+ if (!$arg) {
403+ $arg = $defaultpage;
404+ }
408405 $get['page'] = $post['page'] = $vars['page'] = $arg;
409406 }
410407
--- a/pukiwiki.ini.php
+++ b/pukiwiki.ini.php
@@ -543,6 +543,10 @@ $logging_updates = 0;
543543 $logging_updates_log_dir = '/var/log/pukiwiki';
544544
545545 /////////////////////////////////////////////////
546+// Page-URI mapping handler
547+$pkwk_page_uri_handler = new PukiWikiStandardPageURIHandler();
548+
549+/////////////////////////////////////////////////
546550 // User-Agent settings
547551 //
548552 // If you want to ignore embedded browsers for rich-content-wikisite,