Skip to content

Commit

Permalink
Item11755: make sure that all special characters are treated equal
Browse files Browse the repository at this point in the history
Some parts of processing in Compare push text nodes through entity encoding
and some others do not. Given a site charset of UTF-8, this will invariably
land us in a situation where either the encoded characters are broken or the
non-encoded ones are.

Bypass this problem by entity-encoding only those characters that absolutely
must be, therefore excluding all problematic high-bit bytes/characters.

git-svn-id: http://svn.foswiki.org/branches/Release01x01@15831 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Nov 1, 2012
1 parent 50aab1c commit ffdf600
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ sub _getTree {
my $tree = new HTML::TreeBuilder;
$tree->implicit_body_p_tag(1);
$tree->p_strict(1);
$text = Encode::decode( $Foswiki::cfg{Site}{CharSet}, $text );
$tree->parse($text);
$tree->eof;
$tree->elementify;
Expand Down Expand Up @@ -430,7 +429,7 @@ sub _findSubChanges {
sub _elementHash {

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

# Strip leading & trailing blanks in text and paragraphs
$text =~ s/^\s*//;
Expand Down Expand Up @@ -521,7 +520,9 @@ sub _getTextWithClass {

if ( ref($element) eq $HTMLElement ) {
_addClass( $element, $class ) if $class;
return $element->as_HTML( undef, undef, {} );

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

0 comments on commit ffdf600

Please sign in to comment.