OSDN Git Service

BugTrack2/226 unused $matches (pointed out by anonymous)
[pukiwiki/pukiwiki.git] / lib / plugin.php
index 3f79a1e..bcf35a8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // PukiWiki - Yet another WikiWikiWeb clone.
-// $Id: plugin.php,v 1.14 2005/06/30 13:20:05 henoheno Exp $
+// $Id: plugin.php,v 1.20 2011/01/25 15:01:01 henoheno Exp $
 // Copyright (C)
 //   2002-2005 PukiWiki Developers Team
 //   2001-2002 Originally written by yu-ji
@@ -27,7 +27,7 @@ function exist_plugin($name)
        $name = strtolower($name);
        if(isset($exist[$name])) {
                if (++$count[$name] > PKWK_PLUGIN_CALL_TIME_LIMIT)
-                       die('Alert: plugin "' . htmlspecialchars($name) .
+                       die('Alert: plugin "' . htmlsc($name) .
                        '" was called over ' . PKWK_PLUGIN_CALL_TIME_LIMIT .
                        ' times. SPAM or someting?<br />' . "\n" .
                        '<a href="' . get_script_uri() . '?cmd=edit&amp;page='.
@@ -112,18 +112,30 @@ function do_plugin_convert($name, $args = '')
        if(do_plugin_init($name) === FALSE)
                return '[Plugin init failed: ' . $name . ']';
 
+       if (! PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK) {
+               // Multiline plugin?
+               $pos  = strpos($args, "\r"); // "\r" is just a delimiter
+               if ($pos !== FALSE) {
+                       $body = substr($args, $pos + 1);
+                       $args = substr($args, 0, $pos);
+               }
+       }
+
        if ($args === '') {
                $aryargs = array();                 // #plugin()
        } else {
                $aryargs = csv_explode(',', $args); // #plugin(A,B,C,D)
        }
+       if (! PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK) {
+               if (isset($body)) $aryargs[] = & $body;     // #plugin(){{body}}
+       }
 
        $_digest = $digest;
        $retvar  = call_user_func_array('plugin_' . $name . '_convert', $aryargs);
        $digest  = $_digest; // Revert
 
        if ($retvar === FALSE) {
-               return htmlspecialchars('#' . $name .
+               return htmlsc('#' . $name .
                        ($args != '' ? '(' . $args . ')' : ''));
        } else if (PKWK_ENCODING_HINT != '') {
                // Insert a hidden field, supports idenrtifying text enconding
@@ -158,7 +170,7 @@ function do_plugin_inline($name, $args, & $body)
 
        if($retvar === FALSE) {
                // Do nothing
-               return htmlspecialchars('&' . $name . ($args ? '(' . $args . ')' : '') . ';');
+               return htmlsc('&' . $name . ($args ? '(' . $args . ')' : '') . ';');
        } else {
                return $retvar;
        }