OSDN Git Service

Suppress include-bomb.
authorhenoheno <henoheno>
Mon, 9 Aug 2004 14:47:55 +0000 (23:47 +0900)
committerhenoheno <henoheno>
Mon, 9 Aug 2004 14:47:55 +0000 (23:47 +0900)
* Added define INCLUDE_MAX (default:4 pages at a time)
* Added useful error messages.

plugin/include.inc.php

index 1c28d82..8f1406e 100644 (file)
@@ -2,26 +2,33 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: include.inc.php,v 1.12 2004/08/06 16:06:31 henoheno Exp $
+// $Id: include.inc.php,v 1.13 2004/08/09 14:47:55 henoheno Exp $
 //
 
-// ¥Ú¡¼¥¸¤ò¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
+define('INCLUDE_MAX', 4); // °ìÅÙ¤Ë(Ï¢º¿Åª¤Ë)¥¤¥ó¥¯¥ë¡¼¥É¤Ç¤­¤ëºÇÂç¿ô
+
+// ¥Ú¡¼¥¸¤ò(ºÆµ¢)¥¤¥ó¥¯¥ë¡¼¥É¤¹¤ë
 function plugin_include_convert()
 {
        global $script, $vars, $get, $post, $menubar, $_msg_include_restrict;
        static $included = array();
+       static $count = 0;
+
+       if (func_num_args() == 0) return '#include(): No argument<br />';
 
        // Get an argument
-       if (func_num_args() == 0) return;
        list($page) = func_get_args();
        $page = strip_bracket($page);
+       $s_page = htmlspecialchars($page);
 
        // Loop yourself
        $self = isset($vars['page']) ? $vars['page'] : '';
        $included[$self] = TRUE;
 
        // I'm stuffed
-       if (isset($included[$page]) || ! is_page($page)) return '';
+       if (isset($included[$page])) return "#include(): Already included: $s_page<br />";
+       if (! is_page($page))        return "#include(): No such page: $s_page<br />";
+       if(++$count > INCLUDE_MAX)   return '#include(): Include-max reached(' . INCLUDE_MAX . ")<br />";
 
        // One page, only one time, at a time
        $included[$page] = TRUE;
@@ -36,7 +43,6 @@ function plugin_include_convert()
        $get['page'] = $post['page'] = $vars['page'] = $self;
 
        // Add a title with edit link, before included document
-       $s_page = htmlspecialchars($page);
        $r_page = rawurlencode($page);
        $link = "<a href=\"$script?cmd=edit&amp;page=$r_page\">$s_page</a>";