Skip to content

Commit

Permalink
Item13320: SPACEOUT spaces out the separator
Browse files Browse the repository at this point in the history
Was breaking the backlinks search
  • Loading branch information
gac410 committed Mar 23, 2015
1 parent 3c44351 commit cedd32a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 8 additions & 2 deletions UnitTestContrib/test/unit/FormattingTests.pm
Expand Up @@ -356,28 +356,34 @@ ACTUAL
$this->do_test( $expected, $actual );
}

# Item11671
sub test_Item11671 {
# Item11671 And Item13320
sub test_Item11671_Item13320 {
my $this = shift;

$this->expect_failure("Item11671: Not yet fixed on Release 1.1")
if ( $this->check_dependency('Foswiki,<,1.2') );

my $expected = <<EXPECTED;
<noautolink>
Create A New Wiki Word
Year 2012 A New Year
A 100 Bottle Test
Finishing A 100
Test 100 A
SOS Titanic
TestA2B2A2BTopic
</noautolink>
EXPECTED
my $actual = <<ACTUAL;
<noautolink>
%SPACEOUT{"CreateANewWikiWord"}%
%SPACEOUT{"Year2012ANewYear"}%
%SPACEOUT{"A100BottleTest"}%
%SPACEOUT{"FinishingA100"}%
%SPACEOUT{"Test100A"}%
%SPACEOUT{"SOSTitanic"}%
%SPACEOUT{"Test2Topic" separator="A2B"}%
</noautolink>
ACTUAL
$this->do_test( $expected, $actual );
}
Expand Down
10 changes: 6 additions & 4 deletions core/lib/Foswiki.pm
Expand Up @@ -3100,12 +3100,14 @@ sub spaceOutWikiWord {
# Both could have the value 0 so we cannot use simple = || ''
$word = defined($word) ? $word : '';
$sep = defined($sep) ? $sep : ' ';
$word =~ s/([$regex{upperAlpha}])([$regex{numeric}])/$1$sep$2/g;
$word =~ s/([$regex{numeric}])([$regex{upperAlpha}])/$1$sep$2/g;
my $mark = "\001";
$word =~ s/([$regex{upperAlpha}])([$regex{numeric}])/$1$mark$2/g;
$word =~ s/([$regex{numeric}])([$regex{upperAlpha}])/$1$mark$2/g;
$word =~
s/([$regex{lowerAlpha}])([$regex{upperAlpha}$regex{numeric}]+)/$1$sep$2/g;
s/([$regex{lowerAlpha}])([$regex{upperAlpha}$regex{numeric}]+)/$1$mark$2/g;
$word =~
s/([$regex{upperAlpha}])([$regex{upperAlpha}])(?=[$regex{lowerAlpha}])/$1$sep$2/g;
s/([$regex{upperAlpha}])([$regex{upperAlpha}])(?=[$regex{lowerAlpha}])/$1$mark$2/g;
$word =~ s/$mark/$sep/g;
return $word;
}

Expand Down

0 comments on commit cedd32a

Please sign in to comment.