Skip to content

Commit

Permalink
Item1447: fixed test failure when non iso-8859-1* charset used, and f…
Browse files Browse the repository at this point in the history
…ixed the bug it showed up in the core code

git-svn-id: http://svn.foswiki.org/trunk@3429 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Apr 14, 2009
1 parent e036aea commit da8e737
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
12 changes: 12 additions & 0 deletions UnitTestContrib/test/unit/FormattingTests.pm
Expand Up @@ -563,6 +563,10 @@ EXPECTED

sub test_USInHeader {
my $this = shift;

# Force a site charset that will generate _ in the header
$Foswiki::cfg{Site}{CharSet} = 'iso-8859-1';

my $expected = <<EXPECTED;
<nop><h3><a name="Test_with_link_in_header_Undersc"></a>Test with link in header: Underscore_topic</h3>
EXPECTED
Expand All @@ -571,6 +575,14 @@ EXPECTED
---+++ Test with link in header: Underscore_topic
ACTUAL
$this->do_test( $expected, $actual );

# Repeat with a charset that should generate encoded chars
$Foswiki::cfg{Site}{CharSet} = 'utf-8';
$expected = <<EXPECTED;
<nop><h3><a name="Test%20with%20link%20in%20header:%20Unders"></a>Test with link in header: Underscore_topic</h3>
EXPECTED

$this->do_test( $expected, $actual );
}

sub test_mailWithoutMailto {
Expand Down
19 changes: 9 additions & 10 deletions core/lib/Foswiki/Render.pm
Expand Up @@ -13,27 +13,26 @@ use strict;
use Assert;
use Error qw(:try);

require Foswiki::Time;
use Foswiki::Time ();

# Used to generate unique placeholders for when we lift blocks out of the
# text during rendering.
use vars qw( $placeholderMarker );
$placeholderMarker = 0;
our $placeholderMarker = 0;

# Used to generate unique anchors
my %anchornames = ();
our %anchornames = ();

# limiting lookbehind and lookahead for wikiwords and emphasis
# use like \b
#SMELL: they really limit the number of places emphasis can happen.
my $STARTWW = qr/^|(?<=[\s\(])/m;
my $ENDWW = qr/$|(?=[\s,.;:!?)])/m;
our $STARTWW = qr/^|(?<=[\s\(])/m;
our $ENDWW = qr/$|(?=[\s,.;:!?)])/m;

# marker used to tage the start of a table
my $TABLEMARKER = "\0\1\2TABLE\2\1\0";
our $TABLEMARKER = "\0\1\2TABLE\2\1\0";

# Marker used to indicate table rows that are valid header/footer rows
my $TRMARK = "is\1all\1th";
our $TRMARK = "is\1all\1th";

BEGIN {

Expand Down Expand Up @@ -399,8 +398,8 @@ sub _makeAnchorHeading {
# - filter out $Foswiki::regex{headerPatternNoTOC} ( '!!' and '%NOTOC%' )
my $anchorName = $this->_makeUniqueAnchorName( $topicObject, $text, 0 );

# if the generated uniqe anchor name is 'compatible', it won't change:
my $compatAnchorName = $this->_makeAnchorName( $anchorName, 1 );
# if the generated unique anchor name is 'compatible', it won't change:
my $compatAnchorName = $this->_makeAnchorName( $text, 1 );

# filter '!!', '%NOTOC%'
$text =~ s/$Foswiki::regex{headerPatternNoTOC}//o;
Expand Down

0 comments on commit da8e737

Please sign in to comment.