• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

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

PukiWiki


Commit MetaInfo

修訂15af7eeb428d8a25575d39632902120db3d6178c (tree)
時間2015-01-13 05:54:10
作者umorigu <umorigu@gmai...>
Commiterumorigu

Log Message

BugTrack2/361 Simplify URL. Keep slash / and colon : in page name URL

See: RFC 3986 http://www.ietf.org/rfc/rfc3986.txt - Section 3.4 Query

We don't need to percent encode for slash and colon.

Change Summary

差異

--- a/lib/file.php
+++ b/lib/file.php
@@ -265,7 +265,7 @@ function file_write($dir, $page, $str, $notimestamp = FALSE)
265265 if ($notify_diff_only) $str = preg_replace('/^[^-+].*\n/m', '', $str);
266266 $footer['ACTION'] = 'Page update';
267267 $footer['PAGE'] = & $page;
268- $footer['URI'] = get_script_uri() . '?' . rawurlencode($page);
268+ $footer['URI'] = get_script_uri() . '?' . pagename_urlencode($page);
269269 $footer['USER_AGENT'] = TRUE;
270270 $footer['REMOTE_ADDR'] = TRUE;
271271 pkwk_mail_notify($notify_subject, $str, $footer) or
@@ -800,4 +800,4 @@ function pkwk_touch_file($filename, $time = FALSE, $atime = FALSE)
800800 htmlsc(basename($filename)));
801801 }
802802 }
803-?>
803+
--- a/lib/func.php
+++ b/lib/func.php
@@ -293,6 +293,16 @@ function arg_check($str)
293293 return isset($vars['cmd']) && (strpos($vars['cmd'], $str) === 0);
294294 }
295295
296+function _pagename_urlencode_callback($matches)
297+{
298+ return rawurlencode($matches[0]);
299+}
300+
301+function pagename_urlencode($page)
302+{
303+ return preg_replace_callback('|[^/:]+|', '_pagename_urlencode_callback', $page);
304+}
305+
296306 // Encode page-name
297307 function encode($str)
298308 {
@@ -356,7 +366,7 @@ function page_list($pages, $cmd = 'read', $withfilename = FALSE)
356366 }
357367
358368 foreach($pages as $file=>$page) {
359- $r_page = rawurlencode($page);
369+ $r_page = pagename_urlencode($page);
360370 $s_page = htmlsc($page, ENT_QUOTES);
361371 $passage = get_pg_passage($page);
362372
@@ -774,4 +784,4 @@ if (! function_exists('sha1')) {
774784 }
775785 }
776786 }
777-?>
787+
--- a/lib/html.php
+++ b/lib/html.php
@@ -32,7 +32,7 @@ function catbody($title, $page, $body)
3232 if (! PKWK_ALLOW_JAVASCRIPT) unset($javascript);
3333
3434 $_page = isset($vars['page']) ? $vars['page'] : '';
35- $r_page = rawurlencode($_page);
35+ $r_page = pagename_urlencode($_page);
3636
3737 // Set $_LINK for skin
3838 $_LINK['add'] = "$script?cmd=add&amp;page=$r_page";
@@ -42,18 +42,18 @@ function catbody($title, $page, $body)
4242 $_LINK['edit'] = "$script?cmd=edit&amp;page=$r_page";
4343 $_LINK['filelist'] = "$script?cmd=filelist";
4444 $_LINK['freeze'] = "$script?cmd=freeze&amp;page=$r_page";
45- $_LINK['help'] = "$script?" . rawurlencode($help_page);
45+ $_LINK['help'] = "$script?" . pagename_urlencode($help_page);
4646 $_LINK['list'] = "$script?cmd=list";
4747 $_LINK['new'] = "$script?plugin=newpage&amp;refer=$r_page";
4848 $_LINK['rdf'] = "$script?cmd=rss&amp;ver=1.0";
49- $_LINK['recent'] = "$script?" . rawurlencode($whatsnew);
49+ $_LINK['recent'] = "$script?" . pagename_urlencode($whatsnew);
5050 $_LINK['reload'] = "$script?$r_page";
5151 $_LINK['rename'] = "$script?plugin=rename&amp;refer=$r_page";
5252 $_LINK['rss'] = "$script?cmd=rss";
5353 $_LINK['rss10'] = "$script?cmd=rss&amp;ver=1.0"; // Same as 'rdf'
5454 $_LINK['rss20'] = "$script?cmd=rss&amp;ver=2.0";
5555 $_LINK['search'] = "$script?cmd=search";
56- $_LINK['top'] = "$script?" . rawurlencode($defaultpage);
56+ $_LINK['top'] = "$script?" . pagename_urlencode($defaultpage);
5757 $_LINK['unfreeze'] = "$script?cmd=unfreeze&amp;page=$r_page";
5858 $_LINK['upload'] = "$script?plugin=attach&amp;pcmd=upload&amp;page=$r_page";
5959
@@ -285,7 +285,7 @@ function make_related($page, $tag = '')
285285 foreach ($links as $page=>$lastmod) {
286286 if (check_non_list($page)) continue;
287287
288- $r_page = rawurlencode($page);
288+ $r_page = pagename_urlencode($page);
289289 $s_page = htmlsc($page);
290290 $passage = get_passage($lastmod);
291291 $_links[] = $tag ?
@@ -535,4 +535,4 @@ function pkwk_output_dtd($pkwk_dtd = PKWK_DTD_XHTML_1_1, $charset = CONTENT_CHAR
535535 return '<meta http-equiv="content-type" content="text/html; charset=' . $charset . '" />' . "\n";
536536 }
537537 }
538-?>
538+
--- a/lib/make_link.php
+++ b/lib/make_link.php
@@ -307,7 +307,7 @@ EOD;
307307 if (PKWK_ALLOW_RELATIVE_FOOTNOTE_ANCHOR) {
308308 $script = '';
309309 } else {
310- $script = get_script_uri() . '?' . rawurlencode($page);
310+ $script = get_script_uri() . '?' . pagename_urlencode($page);
311311 }
312312
313313 $id = ++$note_id;
@@ -519,7 +519,7 @@ EOD;
519519
520520 $url = get_interwiki_url($name, $this->param);
521521 $this->url = ($url === FALSE) ?
522- $script . '?' . rawurlencode('[[' . $name . ':' . $this->param . ']]') :
522+ $script . '?' . pagename_urlencode('[[' . $name . ':' . $this->param . ']]') :
523523 htmlsc($url);
524524
525525 return parent::setParam(
@@ -713,7 +713,7 @@ function make_pagelink($page, $alias = '', $anchor = '', $refer = '', $isautolin
713713
714714 if ($page == '') return '<a href="' . $anchor . '">' . $s_alias . '</a>';
715715
716- $r_page = rawurlencode($page);
716+ $r_page = pagename_urlencode($page);
717717 $r_refer = ($refer == '') ? '' : '&amp;refer=' . rawurlencode($refer);
718718
719719 if (! isset($related[$page]) && $page !== $vars['page'] && is_page($page))
@@ -851,4 +851,4 @@ function get_interwiki_url($name, $param)
851851
852852 return $url;
853853 }
854-?>
854+
--- a/plugin/amazon.inc.php
+++ b/plugin/amazon.inc.php
@@ -217,7 +217,7 @@ function plugin_amazon_action()
217217 $title = plugin_amazon_get_asin_title();
218218 if ($title == '' || preg_match('#^/#', $s_page)) {
219219 // Invalid page name
220- header('Location: ' . get_script_uri() . '?' . rawurlencode($s_page));
220+ header('Location: ' . get_script_uri() . '?' . pagename_urlencode($s_page));
221221 } else {
222222 $body = '#amazon(' . $asin_all . ',,image)' . "\n" .
223223 '*' . $title . "\n" . $amazon_body;
@@ -461,4 +461,4 @@ function is_asin()
461461 return TRUE;
462462 }
463463 }
464-?>
464+
--- a/plugin/aname.inc.php
+++ b/plugin/aname.inc.php
@@ -102,7 +102,7 @@ function plugin_aname_tag($args = array(), $convert = TRUE)
102102 $id = htmlsc($id); // Insurance
103103 $class = $f_super ? 'anchor_super' : 'anchor';
104104 $attr_id = $f_noid ? '' : ' id="' . $id . '"';
105- $url = $f_full ? get_script_uri() . '?' . rawurlencode($vars['page']) : '';
105+ $url = $f_full ? get_script_uri() . '?' . pagename_urlencode($vars['page']) : '';
106106 if ($body != '') {
107107 $href = ' href="' . $url . '#' . $id . '"';
108108 $title = ' title="' . $id . '"';
@@ -113,4 +113,4 @@ function plugin_aname_tag($args = array(), $convert = TRUE)
113113 return '<a class="' . $class . '"' . $attr_id . $href . $title . '>' .
114114 $body . '</a>';
115115 }
116-?>
116+
--- a/plugin/article.inc.php
+++ b/plugin/article.inc.php
@@ -121,7 +121,7 @@ EOD;
121121 $mailbody .= "\n\n" . '---' . "\n";
122122 $mailbody .= $_msg_article_mail_sender . $post['name'] . ' (' . $now . ')' . "\n";
123123 $mailbody .= $_msg_article_mail_page . $post['refer'] . "\n";
124- $mailbody .= '  URL: ' . $script . '?' . rawurlencode($post['refer']) . "\n";
124+ $mailbody .= ' URL: ' . $script . '?' . pagename_urlencode($post['refer']) . "\n";
125125 $mailbody = mb_convert_encoding($mailbody, 'JIS');
126126
127127 $mailaddheader = 'From: ' . PLUGIN_ARTICLE_MAIL_FROM;
@@ -177,4 +177,4 @@ EOD;
177177
178178 return $string;
179179 }
180-?>
180+
--- a/plugin/attach.inc.php
+++ b/plugin/attach.inc.php
@@ -208,7 +208,7 @@ function attach_upload($file, $page, $pass = NULL)
208208 $footer['PAGE'] = & $page;
209209
210210 $footer['URI'] = get_script_uri() .
211- //'?' . rawurlencode($page);
211+ //'?' . pagename_urlencode($page);
212212
213213 // MD5 may heavy
214214 '?plugin=attach' .
@@ -649,7 +649,7 @@ EOD;
649649 $footer['FILENAME'] = & $this->file;
650650 $footer['PAGE'] = & $this->page;
651651 $footer['URI'] = get_script_uri() .
652- '?' . rawurlencode($this->page);
652+ '?' . pagename_urlencode($this->page);
653653 $footer['USER_AGENT'] = TRUE;
654654 $footer['REMOTE_ADDR'] = TRUE;
655655 pkwk_mail_notify($notify_subject, "\n", $footer) or
@@ -853,4 +853,4 @@ class AttachPages
853853 return "\n" . '<ul>' . "\n" . $ret . '</ul>' . "\n";
854854 }
855855 }
856-?>
856+
--- a/plugin/bugtrack.inc.php
+++ b/plugin/bugtrack.inc.php
@@ -177,7 +177,7 @@ function plugin_bugtrack_action()
177177 $post['version'], $post['body']);
178178
179179 pkwk_headers_sent();
180- header('Location: ' . get_script_uri() . '?' . rawurlencode($page));
180+ header('Location: ' . get_script_uri() . '?' . pagename_urlencode($page));
181181 exit;
182182 }
183183
@@ -351,4 +351,4 @@ function plugin_bugtrack_list_pageinfo($page, $no = NULL, $recurse = TRUE)
351351
352352 return array($page, $no, $summary, $name, $priority, $state, $category);
353353 }
354-?>
354+
--- a/plugin/calendar2.inc.php
+++ b/plugin/calendar2.inc.php
@@ -105,7 +105,7 @@ EOD;
105105 while (checkdate($m_num, $day, $year)) {
106106 $dt = sprintf('%4d-%02d-%02d', $year, $m_num, $day);
107107 $page = $prefix . $dt;
108- $r_page = rawurlencode($page);
108+ $r_page = pagename_urlencode($page);
109109 $s_page = htmlsc($page);
110110
111111 if ($wday == 0 && $day > 1)
@@ -197,4 +197,4 @@ function plugin_calendar2_action()
197197
198198 return $ret;
199199 }
200-?>
200+
--- a/plugin/calendar_viewer.inc.php
+++ b/plugin/calendar_viewer.inc.php
@@ -173,7 +173,7 @@ function plugin_calendar_viewer_convert()
173173 $body = str_replace('$1', $page, $_msg_calendar_viewer_restrict);
174174 }
175175
176- $r_page = rawurlencode($page);
176+ $r_page = pagename_urlencode($page);
177177
178178 if (PLUGIN_CALENDAR_VIEWER_DATE_FORMAT !== FALSE) {
179179 $time = strtotime(basename($page)); // $date_sep must be assumed '-' or ''!
@@ -330,4 +330,4 @@ function plugin_calendar_viewer_isValidDate($aStr, $aSepList = '-/ .')
330330 return FALSE;
331331 }
332332 }
333-?>
333+
--- a/plugin/diff.inc.php
+++ b/plugin/diff.inc.php
@@ -29,7 +29,7 @@ function plugin_diff_view($page)
2929 global $_msg_notfound, $_msg_goto, $_msg_deleted, $_msg_addline, $_msg_delline, $_title_diff;
3030 global $_title_diff_delete;
3131
32- $r_page = rawurlencode($page);
32+ $r_page = pagename_urlencode($page);
3333 $s_page = htmlsc($page);
3434
3535 $menu = array(
@@ -110,4 +110,4 @@ EOD;
110110
111111 return array('msg'=>$_title_diff_delete, 'body'=>$body);
112112 }
113-?>
113+
--- a/plugin/edit.inc.php
+++ b/plugin/edit.inc.php
@@ -236,7 +236,7 @@ function plugin_edit_write()
236236
237237 page_write($page, $postdata, $notimeupdate != 0 && $notimestamp);
238238 pkwk_headers_sent();
239- header('Location: ' . get_script_uri() . '?' . rawurlencode($page));
239+ header('Location: ' . get_script_uri() . '?' . pagename_urlencode($page));
240240 exit;
241241 }
242242
@@ -245,8 +245,7 @@ function plugin_edit_cancel()
245245 {
246246 global $vars;
247247 pkwk_headers_sent();
248- header('Location: ' . get_script_uri() . '?' . rawurlencode($vars['page']));
248+ header('Location: ' . get_script_uri() . '?' . pagename_urlencode($vars['page']));
249249 exit;
250250 }
251251
252-?>
--- a/plugin/include.inc.php
+++ b/plugin/include.inc.php
@@ -78,7 +78,7 @@ function plugin_include_convert()
7878 }
7979
8080 $s_page = htmlsc($page);
81- $r_page = rawurlencode($page);
81+ $r_page = pagename_urlencode($page);
8282 $link = '<a href="' . $script . '?' . $r_page . '">' . $s_page . '</a>'; // Read link
8383
8484 // I'm stuffed
@@ -118,4 +118,4 @@ function plugin_include_convert()
118118
119119 return $body;
120120 }
121-?>
121+
--- a/plugin/navi.inc.php
+++ b/plugin/navi.inc.php
@@ -129,7 +129,7 @@ function plugin_navi_convert()
129129 'prev'=>$prev, 'up'=>$up) as $rel=>$_page) {
130130 if ($_page != '') {
131131 $s_page = htmlsc($_page);
132- $r_page = rawurlencode($_page);
132+ $r_page = pagename_urlencode($_page);
133133 $head_tags[] = ' <link rel="' .
134134 $rel . '" href="' . $script .
135135 '?' . $r_page . '" title="' .
@@ -183,4 +183,4 @@ EOD;
183183 }
184184 return $ret;
185185 }
186-?>
186+
--- a/plugin/paint.inc.php
+++ b/plugin/paint.inc.php
@@ -84,7 +84,7 @@ function plugin_paint_action()
8484 $r_refer = $s_refer = '';
8585 if (array_key_exists('refer',$vars))
8686 {
87- $r_refer = rawurlencode($vars['refer']);
87+ $r_refer = pagename_urlencode($vars['refer']);
8888 $s_refer = htmlsc($vars['refer']);
8989 }
9090 $link = "<p><a href=\"$script?$r_refer\">$s_refer</a></p>";;
@@ -266,4 +266,4 @@ function paint_insert_ref($filename)
266266
267267 return $ret;
268268 }
269-?>
269+
--- a/plugin/pcomment.inc.php
+++ b/plugin/pcomment.inc.php
@@ -58,7 +58,7 @@ function plugin_pcomment_action()
5858 }
5959
6060 pkwk_headers_sent();
61- header('Location: ' . get_script_uri() . '?' . rawurlencode($refer));
61+ header('Location: ' . get_script_uri() . '?' . pagename_urlencode($refer));
6262 exit;
6363 }
6464
@@ -368,4 +368,4 @@ function plugin_pcomment_get_comments($page, $count, $dir, $reply)
368368
369369 return array($comments, $digest);
370370 }
371-?>
371+
--- a/plugin/random.inc.php
+++ b/plugin/random.inc.php
@@ -29,7 +29,7 @@ function plugin_random_convert()
2929 }
3030
3131 return "<p><a href=\"$script?plugin=random&amp;refer=" .
32- rawurlencode($vars['page']) . '">' .
32+ pagename_urlencode($vars['page']) . '">' .
3333 htmlsc($title) . '</a></p>';
3434 }
3535
@@ -51,4 +51,4 @@ function plugin_random_action()
5151
5252 return array('body'=>'','msg'=>'');
5353 }
54-?>
54+
--- a/plugin/recent.inc.php
+++ b/plugin/recent.inc.php
@@ -77,7 +77,7 @@ function plugin_recent_convert()
7777 // No need to link to the page you just read, or notify where you just read
7878 $items .= ' <li>' . $s_page . '</li>' . "\n";
7979 } else {
80- $r_page = rawurlencode($page);
80+ $r_page = pagename_urlencode($page);
8181 $passage = $show_passage ? ' ' . get_passage($time) : '';
8282 $items .= ' <li><a href="' . $script . '?' . $r_page . '"' .
8383 ' title="' . $s_page . $passage . '">' . $s_page . '</a></li>' . "\n";
@@ -88,4 +88,4 @@ function plugin_recent_convert()
8888
8989 return sprintf($_recent_plugin_frame, count($lines), $items);
9090 }
91-?>
91+
--- a/plugin/related.inc.php
+++ b/plugin/related.inc.php
@@ -32,7 +32,7 @@ function plugin_related_action()
3232 }
3333
3434 // Result
35- $r_word = rawurlencode($_page);
35+ $r_word = pagename_urlencode($_page);
3636 $s_word = htmlsc($_page);
3737 $msg = 'Backlinks for: ' . $s_word;
3838 $retval = '<a href="' . $script . '?' . $r_word . '">' .
@@ -45,7 +45,7 @@ function plugin_related_action()
4545 ksort($data, SORT_STRING);
4646 $retval .= '<ul>' . "\n";
4747 foreach ($data as $page=>$time) {
48- $r_page = rawurlencode($page);
48+ $r_page = pagename_urlencode($page);
4949 $s_page = htmlsc($page);
5050 $passage = get_passage($time);
5151 $retval .= ' <li><a href="' . $script . '?' . $r_page . '">' . $s_page .
@@ -55,4 +55,4 @@ function plugin_related_action()
5555 }
5656 return array('msg'=>$msg, 'body'=>$retval);
5757 }
58-?>
58+
--- a/plugin/rename.inc.php
+++ b/plugin/rename.inc.php
@@ -383,7 +383,7 @@ function plugin_rename_proceed($pages, $files, $exists)
383383 if ($page == '') $page = PLUGIN_RENAME_LOGPAGE;
384384
385385 pkwk_headers_sent();
386- header('Location: ' . get_script_uri() . '?' . rawurlencode($page));
386+ header('Location: ' . get_script_uri() . '?' . pagename_urlencode($page));
387387 exit;
388388 }
389389
@@ -423,4 +423,4 @@ function plugin_rename_getselecttag($page)
423423 EOD;
424424
425425 }
426-?>
426+
--- a/plugin/rss.inc.php
+++ b/plugin/rss.inc.php
@@ -38,7 +38,7 @@ function plugin_rss_action()
3838
3939 foreach (file_head($recent, $rss_max) as $line) {
4040 list($time, $page) = explode("\t", rtrim($line));
41- $r_page = rawurlencode($page);
41+ $r_page = pagename_urlencode($page);
4242 $title = mb_convert_encoding($page, 'UTF-8', SOURCE_ENCODING);
4343
4444 switch ($version) {
@@ -82,7 +82,7 @@ EOD;
8282 header('Content-type: application/xml');
8383 print '<?xml version="1.0" encoding="UTF-8"?>' . "\n\n";
8484
85- $r_whatsnew = rawurlencode($whatsnew);
85+ $r_whatsnew = pagename_urlencode($whatsnew);
8686 switch ($version) {
8787 case '0.91':
8888 print '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"' .
@@ -129,4 +129,4 @@ EOD;
129129 }
130130 exit;
131131 }
132-?>
132+
--- a/plugin/topicpath.inc.php
+++ b/plugin/topicpath.inc.php
@@ -49,7 +49,7 @@ function plugin_topicpath_inline()
4949 $topic_path = array();
5050 while (! empty($parts)) {
5151 $_landing = join('/', $parts);
52- $landing = rawurlencode($_landing);
52+ $landing = pagename_urlencode($_landing);
5353 $element = htmlsc(array_pop($parts));
5454 if (! $b_link) {
5555 // This page ($_landing == $page)
@@ -70,4 +70,4 @@ function plugin_topicpath_inline()
7070
7171 return join(PLUGIN_TOPICPATH_TOP_SEPARATOR, array_reverse($topic_path));
7272 }
73-?>
73+
--- a/plugin/tracker.inc.php
+++ b/plugin/tracker.inc.php
@@ -174,7 +174,7 @@ function plugin_tracker_action()
174174 // Writing page data, without touch
175175 page_write($page, join('', $postdata));
176176
177- $r_page = rawurlencode($page);
177+ $r_page = pagename_urlencode($page);
178178
179179 pkwk_headers_sent();
180180 header('Location: ' . get_script_uri() . '?' . $r_page);
--- a/plugin/yetlist.inc.php
+++ b/plugin/yetlist.inc.php
@@ -42,7 +42,7 @@ function plugin_yetlist_action()
4242 $r_refer = '';
4343 $link_refs = array();
4444 foreach ($refer as $_refer) {
45- $r_refer = rawurlencode($_refer);
45+ $r_refer = pagename_urlencode($_refer);
4646 $link_refs[] = '<a href="' . $script . '?' . $r_refer . '">' .
4747 htmlsc($_refer) . '</a>';
4848 }
@@ -73,4 +73,4 @@ function plugin_yetlist_action()
7373
7474 return $retval;
7575 }
76-?>
76+
--- a/skin/keitai.skin.php
+++ b/skin/keitai.skin.php
@@ -59,7 +59,7 @@ if ($rw) {
5959 }
6060 }
6161 }
62-$navi[] = '<a href="' . $script . '?' . rawurlencode($menubar) . '" ' . $accesskey . '="4">4.Menu</a>';
62+$navi[] = '<a href="' . $script . '?' . pagename_urlencode($menubar) . '" ' . $accesskey . '="4">4.Menu</a>';
6363 $navi[] = '<a href="' . $link['recent'] . '" ' . $accesskey . '="5">5.Recent</a>';
6464
6565 // Previous / Next block