summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-08-16 09:27:05 +0300
committerAndrew Dolgov <[email protected]>2019-08-16 09:27:05 +0300
commite53cd12ffd7237af3ffa87431d849db44b892d63 (patch)
tree437d27d3165e6945e8109c0343d9c5d53bb380ec
parent865c54abcb5bdfb6d68757cfadccd8383cdc213c (diff)
pluginhandler: better error reporting for incorrect usage
-rwxr-xr-xclasses/handler/public.php20
-rw-r--r--classes/pluginhandler.php5
2 files changed, 14 insertions, 11 deletions
diff --git a/classes/handler/public.php b/classes/handler/public.php
index 05a84494b..92240fd10 100755
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -1203,30 +1203,30 @@ class Handler_Public extends Handler {
public function pluginhandler() {
$host = new PluginHost();
- $plugin = basename(clean($_REQUEST["plugin"]));
+ $plugin_name = clean_filename($_REQUEST["plugin"]);
$method = clean($_REQUEST["pmethod"]);
- $host->load($plugin, PluginHost::KIND_USER, 0);
+ $host->load($plugin_name, PluginHost::KIND_USER, 0);
$host->load_data();
- $pclass = $host->get_plugin($plugin);
+ $plugin = $host->get_plugin($plugin_name);
- if ($pclass) {
- if (method_exists($pclass, $method)) {
- if ($pclass->is_public_method($method)) {
- $pclass->$method();
+ if ($plugin) {
+ if (method_exists($plugin, $method)) {
+ if ($plugin->is_public_method($method)) {
+ $plugin->$method();
} else {
- user_error("pluginhandler: Requested private method '$method' of plugin '$plugin'.");
+ user_error("PluginHandler[PUBLIC]: Requested private method '$method' of plugin '$plugin_name'.");
header("Content-Type: text/json");
print error_json(6);
}
} else {
- user_error("pluginhandler: Requested unknown method '$method' of plugin '$plugin'.");
+ user_error("PluginHandler[PUBLIC]: Requested unknown method '$method' of plugin '$plugin_name'.");
header("Content-Type: text/json");
print error_json(13);
}
} else {
- user_error("pluginhandler: Requested method '$method' of unknown plugin '$plugin'.");
+ user_error("PluginHandler[PUBLIC]: Requested method '$method' of unknown plugin '$plugin_name'.");
header("Content-Type: text/json");
print error_json(14);
}
diff --git a/classes/pluginhandler.php b/classes/pluginhandler.php
index d10343e09..9682e440f 100644
--- a/classes/pluginhandler.php
+++ b/classes/pluginhandler.php
@@ -5,15 +5,18 @@ class PluginHandler extends Handler_Protected {
}
function catchall($method) {
- $plugin = PluginHost::getInstance()->get_plugin(clean($_REQUEST["plugin"]));
+ $plugin_name = clean($_REQUEST["plugin"]);
+ $plugin = PluginHost::getInstance()->get_plugin($plugin_name);
if ($plugin) {
if (method_exists($plugin, $method)) {
$plugin->$method();
} else {
+ user_error("PluginHandler: Requested unknown method '$method' of plugin '$plugin_name'.", E_USER_WARNING);
print error_json(13);
}
} else {
+ user_error("PluginHandler: Requested method '$method' of unknown plugin '$plugin_name'.", E_USER_WARNING);
print error_json(14);
}
}