diff --git a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm index 690905d779..bf505320db 100644 --- a/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm +++ b/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm @@ -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 diff --git a/lib/WeBWorK/ContentGenerator/Instructor/ProblemGrader.pm b/lib/WeBWorK/ContentGenerator/Instructor/ProblemGrader.pm index 4db7a37545..e849ce9b0a 100644 --- a/lib/WeBWorK/ContentGenerator/Instructor/ProblemGrader.pm +++ b/lib/WeBWorK/ContentGenerator/Instructor/ProblemGrader.pm @@ -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) { diff --git a/lib/WeBWorK/ContentGenerator/Problem.pm b/lib/WeBWorK/ContentGenerator/Problem.pm index 38b20ce3cb..c5dfa4c2ea 100644 --- a/lib/WeBWorK/ContentGenerator/Problem.pm +++ b/lib/WeBWorK/ContentGenerator/Problem.pm @@ -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