Navigation Menu

Skip to content

Commit

Permalink
Item13817: Avoid encoding double-quotes where possible
Browse files Browse the repository at this point in the history
By generating HTML using single-quote delimiters we can avoid encoding "
into " entities.  Large numbers of entities places a huge load on
the render regular expressions. One example table had over 21,000
encoded entities. This change dropped it down to around 2000.
  • Loading branch information
gac410 committed Oct 23, 2015
1 parent 5c91079 commit 71ec749
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions EditRowPlugin/lib/Foswiki/Plugins/EditRowPlugin.pm
Expand Up @@ -22,8 +22,8 @@ BEGIN {
# SMELL: make the sort conditional on DEBUG
foreach my $k ( sort keys %$attrs ) {
my $v = $attrs->{$k};
$v =~ s/([&<>"\x8b\x9b'])/'&#'.ord($1).';'/ge;
$html .= " $k=\"$v\"";
$v =~ s/([&<>\x8b\x9b'])/'&#'.ord($1).';'/ge;
$html .= " $k='$v'";
}
}
$innerHTML = '' unless defined $innerHTML;
Expand Down
4 changes: 2 additions & 2 deletions EditRowPlugin/test/unit/EditRowPlugin/HTML.pm
Expand Up @@ -66,7 +66,7 @@ HTML
'#' => "erp_TABLE_0"
);
my $expected = <<EXPECTED;
<a name='erp_TABLE_0'></a><a href='$viewurl' title='Edit full table'><button type="button" name="erp_edit_TABLE_0" title="Edit full table" class="erp-edittable"></button></a><br />
<a name='erp_TABLE_0'></a><a href='$viewurl' title='Edit full table'><button type='button' name='erp_edit_TABLE_0' title='Edit full table' class='erp-edittable'></button></a><br />
EXPECTED
$this->assert_html_equals( $expected, $1 );
$in =~ s/&quot;1_\d+&quot;/&quot;VERSION&quot;/gs;
Expand Down Expand Up @@ -110,7 +110,7 @@ EXPECTED
width => "20em",
loadurl => $loadurl,
submit =>
'<button class="ui-icon ui-icon-disk erp-button" type="submit"></button>',
"<button class='ui-icon ui-icon-disk erp-button' type='submit'></button>",
name => "CELLDATA",
type => "text",
col => 0,
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Foswiki/Render.pm
Expand Up @@ -598,8 +598,8 @@ sub html {
my $v = $attrs->{$k};

# This is what CGI encodes, so....
$v =~ s/([&<>"\x8b\x9b'])/'&#'.ord($1).';'/ge;
$html .= " $k=\"$v\"";
$v =~ s/([&<>\x8b\x9b'])/'&#'.ord($1).';'/ge;
$html .= " $k='$v'";
}
}
$innerHTML = '' unless defined $innerHTML;
Expand Down

0 comments on commit 71ec749

Please sign in to comment.