Skip to content

Commit

Permalink
Removing scrubber
Browse files Browse the repository at this point in the history
  • Loading branch information
goehle committed Sep 10, 2013
1 parent 12d369c commit b998ea4
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 57 deletions.
1 change: 0 additions & 1 deletion conf/defaults.config
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,6 @@ $pg{specialPGEnvironmentVars}{problemPostamble} = { TeX => '', HTML=>'' };
# should appear as [qw(Mymodule.pm, Dependency1.pm, Dependency2.pm)]

${pg}{modules} = [
[qw(HTML::Scrubber)],
[qw(HTML::Parser)],
[qw(HTML::Entities)],
[qw(DynaLoader)],
Expand Down
22 changes: 0 additions & 22 deletions lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ use WeBWorK::Utils::Tasks qw(fake_set fake_set_version fake_problem);
use WeBWorK::Debug;
use WeBWorK::ContentGenerator::Instructor qw(assignSetVersionToUser);
use PGrandom;
use HTML::Scrubber;

# template method
sub templateName {
Expand Down Expand Up @@ -1010,27 +1009,6 @@ sub pre_header_initialize {

my $formFields = { WeBWorK::Form->new_from_paramable($r)->Vars };

##### scrub answer fields for xss badness #####
my $scrubber = HTML::Scrubber->new(
default=> 1,
script => 0,
process => 0,
comment => 1
);
foreach my $key (keys %$formFields) {
if ($key =~ /AnSwEr/) {
$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
$formFields->{$key} =~ s/&lt;/</g;
$formFields->{$key} =~ s/&gt;/>/g;
}
}


$self->{displayMode} = $displayMode;
$self->{redisplay} = $redisplay;
$self->{submitAnswers} = $submitAnswers;
Expand Down
13 changes: 0 additions & 13 deletions lib/WeBWorK/ContentGenerator/Instructor/ProblemGrader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package WeBWorK::ContentGenerator::Instructor::ProblemGrader;
use base qw(WeBWorK::ContentGenerator);
use WeBWorK::Utils qw(sortByName );
use WeBWorK::PG;
use HTML::Scrubber;

=head1 NAME
Expand Down Expand Up @@ -130,18 +129,6 @@ sub initialize {
#if the instructor added a comment we should save that to the latest answer
if ($r->param("$userID.comment")) {

### $comment needs to be sanitized. It could currently contain badness written
### into the comment by the instructor


my $scrubber = HTML::Scrubber->new(
default=> 1,
script => 0,
process => 0,
comment => 1
);

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
22 changes: 1 addition & 21 deletions lib/WeBWorK/ContentGenerator/Problem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ use URI::Escape;
use WeBWorK::Localize;
use WeBWorK::Utils::Tasks qw(fake_set fake_problem);
use WeBWorK::AchievementEvaluator;
use HTML::Scrubber;

################################################################################
# CGI param interface to this module (up-to-date as of v1.153)
Expand Down Expand Up @@ -723,26 +722,7 @@ sub pre_header_initialize {
$formFields->{$_} = $oldAnswers{$_} foreach keys %oldAnswers;
}

##### scrub answer fields for xss badness #####
my $scrubber = HTML::Scrubber->new(
default=> 1,
script => 0,
process => 0,
comment => 1
);
foreach my $key (keys %$formFields) {
if ($key =~ /AnSwEr/) {
$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
$formFields->{$key} =~ s/&lt;/</g;
$formFields->{$key} =~ s/&gt;/>/g;
}
}


##### translation #####

debug("begin pg processing");
Expand Down

0 comments on commit b998ea4

Please sign in to comment.