Skip to content
Permalink
Browse files

Item11755: fix by completely disabling all entity processing

If we don't let HTML::TreeBuilder decode entities in the first place, we know
that all text nodes contain proper HTML entities and so we can skip
re-encoding things. This means we remove potentially fault-inducing steps of
processing which is a Good Thing™ and certainly beats the previous attempt at
fixing the problem in every way.


git-svn-id: http://svn.foswiki.org/trunk@15782 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information...
JanKrueger JanKrueger
JanKrueger authored and JanKrueger committed Oct 30, 2012
1 parent 548a152 commit fd699b2af5348eb3ea18b85bd1a1abd1fc1b70c7
Showing with 5 additions and 3 deletions.
  1. +5 −3 CompareRevisionsAddOn/lib/Foswiki/Contrib/CompareRevisionsAddOn/Compare.pm
@@ -328,6 +328,7 @@ sub _getTree {

my $tree = new HTML::TreeBuilder;
$tree->implicit_body_p_tag(1);
$tree->no_expand_entities(1); # Item11755
$tree->p_strict(1);
$tree->parse($text);
$tree->eof;
@@ -428,7 +429,8 @@ sub _findSubChanges {
sub _elementHash {

# Purpose: Stringify HTML ELement for comparison in Algorithm::Diff
my $text = ref( $_[0] ) eq $HTMLElement ? $_[0]->as_HTML('<>&') : "$_[0]";
# Item11755: prevent entity mangling
my $text = ref( $_[0] ) eq $HTMLElement ? $_[0]->as_HTML('') : "$_[0]";

# Strip leading & trailing blanks in text and paragraphs
$text =~ s/^\s*//;
@@ -520,8 +522,8 @@ sub _getTextWithClass {
if ( ref($element) eq $HTMLElement ) {
_addClass( $element, $class ) if $class;

# Don't let HTML::Entities touch high-bit bytes (Item11755)
return $element->as_HTML( '<>&', undef, {} );
# Item11755: prevent entity mangling
return $element->as_HTML( '', undef, {} );
}
elsif ($class) {
return '<span class="' . $class . '">' . $element . '</span>';

0 comments on commit fd699b2

Please sign in to comment.
You can’t perform that action at this time.