From f598474aeb237e18b90720797bcc274e4675dddb Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sat, 3 Nov 2018 23:18:34 +1300 Subject: Add sanity check to plugin loading --- Plugin.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Plugin.pm b/Plugin.pm index 1f3d080..6714987 100644 --- a/Plugin.pm +++ b/Plugin.pm @@ -17,12 +17,18 @@ sub load_plugin { eval { require $path . ".pm"; - push @{$config->{active_plugins}}, $module; } or do { chomp $@; $logger->($@); return "Cannot load $module: $!"; }; + + if (not $module->can("configure")) { + $logger->("Loaded $module but it can't be configured. Probably not a module for us"); + return "Can't configure $module. It probably isn't a module for me. Unloaded it."; + } + + push @{$config->{active_plugins}}, $module; $load_callback->($module); return undef; } -- cgit v1.1