Skip to content

Commit

Permalink
Protect HTML::Scrubber from being fed an undefined variable.
Browse files Browse the repository at this point in the history
This can be more elegantly done using the // construction but that
breaks perl 5.8   -- so we'll do it this way for now.
  • Loading branch information
mgage committed Jun 8, 2013
1 parent 13cf324 commit d74ff57
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,9 @@ sub pre_header_initialize {
);
foreach my $key (keys %$formFields) {
if ($key =~ /AnSwEr/) {
$formFields->{$key} = $scrubber->scrub($formFields->{$key});
$formFields->{$key} = $scrubber->scrub(
(defined $formFields->{$key})? $formFields->{key}:'' # using // would be more elegant but breaks perl 5.8.x
);
### HTML::scrubber is a little too enthusiastic about
### removing > and < so we have to add them back in otherwise
### they confuse pg
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/ContentGenerator/Instructor/ProblemGrader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ sub initialize {
comment => 0
);

my $comment = $scrubber->scrub($r->param("$userID.comment"));
my $comment = $scrubber->scrub( ( defined $r->param("$userID.comment") )?$r->param("$userID.comment"):'' );
my $userPastAnswerID = $db->latestProblemPastAnswer($courseName, $userID, $setID, $problemID);

if ($userPastAnswerID) {
Expand Down
4 changes: 3 additions & 1 deletion lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,9 @@ sub pre_header_initialize {
);
foreach my $key (keys %$formFields) {
if ($key =~ /AnSwEr/) {
$formFields->{$key} = $scrubber->scrub($formFields->{$key});
$formFields->{$key} = $scrubber->scrub(
(defined $formFields->{$key})? $formFields->{key}:'' # using // would be more elegant but breaks perl 5.8.x
);
### HTML::scrubber is a little too enthusiastic about
### removing > and < so we have to add them back in otherwise
### they confuse pg
Expand Down

0 comments on commit d74ff57

Please sign in to comment.