1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-22 03:31:29 +00:00

pluginhandler: better error reporting for incorrect usage

This commit is contained in:
Andrew Dolgov
2019-08-16 09:27:05 +03:00
parent 865c54abcb
commit e53cd12ffd
2 changed files with 14 additions and 11 deletions

View File

@@ -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);
}