• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythonwindowsphpgamebathyscapheguic翻訳omegattwitterframeworkbtronvb.net計画中(planning stage)testdomarduinodirectxpreviewerゲームエンジン

Commit MetaInfo

Revisione60426e07050026cd8848d92ccea0f9bb98011b1 (tree)
Time2015-01-13 05:54:10
Authorumorigu <umorigu@gmai...>
Commiterumorigu

Log Message

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

Incremental Difference

--- 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
--- 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
--- 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
--- 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(
--- 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;
--- 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 . '"';
--- 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;
--- 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
--- 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
--- 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)
--- 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 ''!
--- 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(
--- 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,7 +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
--- 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
--- 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="' .
--- 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>";;
--- 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
--- 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
--- a/plugin/recent.inc.php
+++ b/plugin/recent.inc.php
@@ -73,7 +73,7 @@ function plugin_recent_convert()
7373 // No need to link to the page you just read, or notify where you just read
7474 $items .= ' <li>' . $s_page . '</li>' . "\n";
7575 } else {
76- $r_page = rawurlencode($page);
76+ $r_page = pagename_urlencode($page);
7777 $passage = $show_passage ? ' ' . get_passage($time) : '';
7878 $items .= ' <li><a href="' . $script . '?' . $r_page . '"' .
7979 ' title="' . $s_page . $passage . '">' . $s_page . '</a></li>' . "\n";
--- 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 .
--- 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
--- 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"' .
--- 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)
--- 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 }
--- 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