fix: workflow helpers and form helpers now use UNIVERSAL->can instead of evil evals
This commit is contained in:
parent
155fc93575
commit
10e5e90668
2 changed files with 34 additions and 20 deletions
|
|
@ -42,24 +42,31 @@ parameters you wish the form helper to use. Here's an example:
|
|||
=cut
|
||||
|
||||
sub www_formHelper {
|
||||
my $session = shift;
|
||||
my $form = $session->form;
|
||||
my $class = "WebGUI::Form::".$form->get("class");
|
||||
my $sub = $form->get("sub");
|
||||
my $session = shift;
|
||||
my $form = $session->form;
|
||||
my $class = "WebGUI::Form::".$form->get("class");
|
||||
my $sub = $form->get("sub");
|
||||
return "ERROR" unless (defined $sub && defined $class);
|
||||
|
||||
# Load the form helper class
|
||||
my $load = "use ".$class;
|
||||
eval($load);
|
||||
if ($@) {
|
||||
$session->errorHandler->error("Couldn't load form helper class $class because $@");
|
||||
return "ERROR";
|
||||
}
|
||||
my $output = "";
|
||||
my $command = $class.'::www_'.$sub;
|
||||
no strict;
|
||||
my $output = eval { &$command($session) };
|
||||
use strict;
|
||||
|
||||
# Make sure the subroutine exists
|
||||
my $command = $class->can('www_'.$sub);
|
||||
if (!$command) {
|
||||
$session->errorHandler->error("Could not execute form helper: Couldn't find subroutine www_$sub via class $class");
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
# Run the subroutine
|
||||
my $output = eval { $command->($session) };
|
||||
if ($@) {
|
||||
$session->errorHandler->error("Couldn't execute form helper subroutine $sub because $@");
|
||||
$session->errorHandler->error("Couldn't execute form helper ${class}::www_${sub} because $@");
|
||||
return "ERROR";
|
||||
}
|
||||
return $output;
|
||||
|
|
|
|||
|
|
@ -74,24 +74,31 @@ parameters you wish the activity helper to use. Here's an example:
|
|||
=cut
|
||||
|
||||
sub www_activityHelper {
|
||||
my $session = shift;
|
||||
my $form = $session->form;
|
||||
my $class = "WebGUI::Workflow::Activity::".$form->get("class");
|
||||
my $sub = $form->get("sub");
|
||||
my $session = shift;
|
||||
my $form = $session->form;
|
||||
my $class = "WebGUI::Workflow::Activity::".$form->get("class");
|
||||
my $sub = $form->get("sub");
|
||||
return "ERROR" unless (defined $sub && defined $class);
|
||||
|
||||
# Load the modules
|
||||
my $load = "use ".$class;
|
||||
eval($load);
|
||||
if ($@) {
|
||||
$session->errorHandler->error("Couldn't load activity helper class $class because $@");
|
||||
return "ERROR";
|
||||
}
|
||||
my $output = "";
|
||||
my $command = $class.'::www_'.$sub;
|
||||
no strict;
|
||||
my $output = eval { &$command($session) };
|
||||
use strict;
|
||||
|
||||
# Make sure the subroutine exists
|
||||
my $command = $class->can('www_'.$sub);
|
||||
if (!$command) {
|
||||
$session->errorHandler->error("Couldn't execute activity helper ${class}::www_${sub} because subroutine does not exist");
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
# Execute
|
||||
my $output = eval { $command->($session) };
|
||||
if ($@) {
|
||||
$session->errorHandler->error("Couldn't execute activity helper subroutine $sub because $@");
|
||||
$session->errorHandler->error("Couldn't execute activity helper ${class}::www_${sub} because $@");
|
||||
return "ERROR";
|
||||
}
|
||||
return $output;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue