• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Revision3cd16deb819809263f898d5527f235e55ea15d3d (tree)
Time2014-11-29 14:58:44
Authorhenoheno <henoheno>
Commiterumorigu

Log Message

BugTrack2/246: do_plugin_init(): KISS.
* This API do one thing: "FALSE or not". Forget meanless rule about NULL.
* htmlspecialchars() everywhere.

Change Summary

Incremental Difference

--- a/lib/plugin.php
+++ b/lib/plugin.php
@@ -68,19 +68,14 @@ function exist_plugin_inline($name) {
6868 }
6969
7070 // Do init the plugin
71+// NOTE: Returning FALSE from $func, means "an erorr occurerd"
7172 function do_plugin_init($name)
7273 {
7374 static $checked = array();
7475
75- // TRUE or FALSE or NULL (Return nothing / Not exists)
76- if (array_key_exists($name, $checked)) return $checked[$name];
77-
78- $func = 'plugin_' . $name . '_init';
79- if (function_exists($func)) {
80- $result = call_user_func($func);
81- $checked[$name] = ($result === NULL) ? NULL : (bool)$result;
82- } else {
83- $checked[$name] = NULL;
76+ if (! isset($checked[$name])) {
77+ $func = 'plugin_' . $name . '_init';
78+ $checked[$name] = (! function_exists($func) || call_user_func($func) !== FALSE);
8479 }
8580
8681 return $checked[$name];
@@ -91,8 +86,9 @@ function do_plugin_action($name)
9186 {
9287 if (! exist_plugin_action($name)) return array();
9388
94- if(do_plugin_init($name) === FALSE)
95- die_message('Plugin init failed: ' . $name);
89+ if (do_plugin_init($name) === FALSE) {
90+ die_message('Plugin init failed: ' . htmlspecialchars($name));
91+ }
9692
9793 $retvar = call_user_func('plugin_' . $name . '_action');
9894
@@ -110,8 +106,9 @@ function do_plugin_convert($name, $args = '')
110106 {
111107 global $digest;
112108
113- if(do_plugin_init($name) === FALSE)
114- return '[Plugin init failed: ' . $name . ']';
109+ if (do_plugin_init($name) === FALSE) {
110+ return '[Plugin init failed: ' . htmlspecialchars($name) . ']';
111+ }
115112
116113 if (! PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK) {
117114 // Multiline plugin?
@@ -153,13 +150,14 @@ function do_plugin_inline($name, $args, & $body)
153150 {
154151 global $digest;
155152
156- if(do_plugin_init($name) === FALSE)
157- return '[Plugin init failed: ' . $name . ']';
153+ if (do_plugin_init($name) === FALSE) {
154+ return '[Plugin init failed: ' . htmlspecialchars($name) . ']';
155+ }
158156
159- if ($args !== '') {
160- $aryargs = csv_explode(',', $args);
161- } else {
157+ if ($args === '') {
162158 $aryargs = array();
159+ } else {
160+ $aryargs = csv_explode(',', $args);
163161 }
164162
165163 // NOTE: A reference of $body is always the last argument