Skip to content

Commit

Permalink
Item13331: Encode some entitites
Browse files Browse the repository at this point in the history
Minor updates to get unit test to pass.
  • Loading branch information
gac410 committed Apr 17, 2015
1 parent 702d880 commit c3fa375
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion UnitTestContrib/test/unit/ViewScriptTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ my $topic2metaQ = $topic2meta;
$topic2metaQ =~ s/"/"/g;

my $topic2txtarea =
'<textarea name="" rows="22" cols="70" readonly="readonly" style="width:99%" id="topic" class="foswikiTextarea foswikiTextareaRawView">';
"<textarea class='foswikiTextarea foswikiTextareaRawView' cols='70' readonly='readonly' rows='22' style='width:99%' id='topic'>";

my $topic2rawON = $topic2;
$topic2rawON =~ s/</&lt;/g;
Expand Down Expand Up @@ -246,6 +246,7 @@ sub test_render_raw {

( $text, $hdr ) =
$this->setup_view( $this->{test_web}, 'TestTopic2', 'viewfour', 'on' );

$this->assert_html_matches( $topic2txtarea . $topic2rawON,
$text, "Unexpected output from raw=on" );
$this->assert_matches( qr#^Content-Type: text/html#ms,
Expand Down
7 changes: 7 additions & 0 deletions core/lib/Foswiki/Render/HTML.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ sub textarea {
my $id = $ah->{id};
my $default = $ah->{default};

#$default =~ s/([<>%'"])/'&#'.ord($1).';'/ge;

$default =~ s/&/&amp;/g;
$default =~ s/</&lt;/g;
$default =~ s/>/&gt;/g;
$default =~ s/"/&quot;/g;

print STDERR Data::Dumper::Dumper( \$ah );

my $html = '<textarea ';
Expand Down

0 comments on commit c3fa375

Please sign in to comment.