string evals are evil

This commit is contained in:
Graham Knop 2009-05-29 21:41:52 +00:00
parent c0d7357429
commit 66843db604
5 changed files with 16 additions and 16 deletions

View file

@ -21,6 +21,7 @@ use Params::Validate qw(:all);
use Safe;
use List::Util qw/sum/;
use WebGUI::Asset;
use WebGUI::Asset::Wobject::Survey;
Params::Validate::validation_options( on_fail => sub { WebGUI::Error::InvalidParam->throw( error => shift ) } );
# We need these as semi-globals so that utility subs (which are shared with the safe compartment)
@ -534,7 +535,6 @@ sub run {
$session->log->debug("Using responseId: $mostRecentlyCompletedResponseId");
# (re)Instantiate the survey instance using the responseId
use WebGUI::Asset::Wobject::Survey;
$asset = WebGUI::Asset::Wobject::Survey->newByResponseId( $session, $mostRecentlyCompletedResponseId );
if ( !$asset ) {
$session->log->warn("Unable to instantiate asset by responseId: $mostRecentlyCompletedResponseId");
@ -562,4 +562,4 @@ sub run {
}
}
1;
1;

View file

@ -47,6 +47,7 @@ use Params::Validate qw(:all);
use List::Util qw(shuffle);
use Clone qw/clone/;
use Safe;
use WebGUI::Asset::Wobject::Survey::ExpressionEngine;
Params::Validate::validation_options( on_fail => sub { WebGUI::Error::InvalidParam->throw( error => shift ) } );
#-------------------------------------------------------------------
@ -816,7 +817,6 @@ sub processExpression {
my $tags = $self->tags;
my %validTargets = map { $_ => 1 } @{$self->survey->getGotoTargets};
use WebGUI::Asset::Wobject::Survey::ExpressionEngine;
my $engine = "WebGUI::Asset::Wobject::Survey::ExpressionEngine";
if (my $result = $engine->run($self->session, $expression, { values => $values, scores => $scores, tags => $tags, validTargets => \%validTargets} ) ) {
# Update tags

View file

@ -48,11 +48,11 @@ likely operate on the question indexed by:
use strict;
use JSON;
use Data::Dumper;
use Params::Validate qw(:all);
Params::Validate::validation_options( on_fail => sub { WebGUI::Error::InvalidParam->throw( error => shift ) } );
use Clone qw/clone/;
use WebGUI::Asset::Wobject::Survey::ExpressionEngine;
# The maximum value of questionsPerPage is currently hardcoded here
my $MAX_QUESTIONS_PER_PAGE = 20;
@ -1314,7 +1314,6 @@ sub validateGotoExpression{
return 'enableSurveyExpressionEngine is disabled in your site config!';
}
use WebGUI::Asset::Wobject::Survey::ExpressionEngine;
my $engine = "WebGUI::Asset::Wobject::Survey::ExpressionEngine";
return $engine->run($self->session, $object->{gotoExpression}, { validate => 1, validTargets => $goodTargets } );
}