Navigation Menu

Skip to content

Commit

Permalink
Item12391: Better Maketext fix
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@16535 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Feb 13, 2013
1 parent 2f42e93 commit b674a61
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 22 additions & 0 deletions UnitTestContrib/test/unit/Fn_MAKETEXT.pm
Expand Up @@ -140,6 +140,28 @@ sub test_escaping {
' This \\\'.`echo A`.\\\' 1 \\\'.`echo A`.\\\' ', $result );
}

sub test_escaping_brackets {
my $this = shift;

# Make sure the real Locale::Maketext gets called
$Foswiki::cfg{UserInterfaceInternationalisation} = 1;

my $str = ' %MAKETEXT{"~~[quant,4,singular,plural~~]"}% ';

my $result = $topicObject->expandMacros($str);
$this->assert_str_equals( ' [quant,4,singular,plural] ', $result );

$str = ' %MAKETEXT{"~~~[quant,4,singular,plural~~~]"}% ';

$result = $topicObject->expandMacros($str);
$this->assert_str_equals( ' [quant,4,singular,plural] ', $result );

$str = ' %MAKETEXT{"~~~~[quant,4,singular,plural~~~]"}% ';

$result = $topicObject->expandMacros($str);
$this->assert_str_equals( ' [quant,4,singular,plural] ', $result );
}

sub test_invalid_args {
my $this = shift;

Expand Down
4 changes: 2 additions & 2 deletions core/lib/Foswiki/Macros/MAKETEXT.pm
Expand Up @@ -17,8 +17,8 @@ sub MAKETEXT {
$str =~ s/\]/~]/g;

# restore already escaped stuff:
$str =~ s/~~\[/~[/g;
$str =~ s/~~\]/~]/g;
$str =~ s/~~+\[/~[/g;
$str =~ s/~~+\]/~]/g;

my $max = 0;
my $min = 1;
Expand Down

0 comments on commit b674a61

Please sign in to comment.