Skip to content

Commit

Permalink
Item11501: Change the encoding
Browse files Browse the repository at this point in the history
expandCommonVariables was doing too much.   Change to use the safe
encoding regex from ENCODE .pm

git-svn-id: http://svn.foswiki.org/branches/Release01x01@13925 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Feb 5, 2012
1 parent 0a31474 commit 2d66935
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 10 additions & 5 deletions UnitTestContrib/test/unit/RegisterTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -911,17 +911,22 @@ sub verify_rejectEvilContent {
}
catch Foswiki::OopsException with {
my $e = shift;
$this->assert_str_equals( "200", $e->{status},
$e->stringify() );
$this->assert_matches( qr/.*Comment: %3cblah%3e.*Organization: %3cscript%3eBad%20stuff%3c\/script%3e/ms, $FoswikiFnTestCase::mails[0] );
$this->assert_str_equals( "200", $e->{status}, $e->stringify() );
$this->assert_matches(
qr/.*Comment: <blah>.*Organization: <script>Bad stuff<\/script>/ms,
$FoswikiFnTestCase::mails[0]
);

my ($meta) = Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName},
$this->{new_user_wikiname} );
my $text = $meta->text;
$meta->finish();
$this->assert_matches( qr/.*Comment: %3cblah%3e.*Organization: %3cscript%3eBad%20stuff%3c\/script%3e/ms, $text );
$this->assert_matches(
qr/.*Comment: <blah>.*Organization: <script>Bad stuff<\/script>/ms,
$text
);

return;
return;

}
catch Foswiki::AccessControlException with {
Expand Down
3 changes: 2 additions & 1 deletion core/lib/Foswiki/UserMapping.pm
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,8 @@ sub validateRegistrationField {
#my $value = Foswiki::Macros::ENCODE->ENCODE( $session, { type => 'safe', _DEFAULT => $_[2] } );
#print STDERR "Encoding $_[1] as $value\n";

$_[2] = Foswiki::Func::expandCommonVariables("%ENCODE{\"$_[2]\"}%");
# This is the "safe" encode in ENCODE.pm
$_[2] =~ s/([<>%'"])/'&#'.ord($1).';'/ge;
}

# Don't allow html markup in any other fields.
Expand Down

0 comments on commit 2d66935

Please sign in to comment.