Skip to content

Commit

Permalink
Item12285: More changes...
Browse files Browse the repository at this point in the history
Do need to escape the whole string, and perl might not support VERSION()
method.

git-svn-id: http://svn.foswiki.org/trunk@16190 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Dec 11, 2012
1 parent 707c599 commit 619cd7c
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions core/lib/Foswiki/Macros/MAKETEXT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use warnings;

use Locale::Maketext;
my $escape =
( $Foswiki::cfg{UserInterfaceInternationalisation}
&& ( Locale::Maketext->VERSION() < 1.23 ) );
( $Foswiki::cfg{UserInterfaceInternationalisation}
&& $Locale::Maketext::VERSION
&& $Locale::Maketext::VERSION < 1.23 );

sub MAKETEXT {
my ( $this, $params ) = @_;
Expand All @@ -34,12 +35,15 @@ sub MAKETEXT {
# unescape parameters and calculate highest parameter number:
$str =~ s/~\[(\_(\d+))~\]/_validate($1, $2, $max, $min, $param_error)/ge;
$str =~
s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, $max, $min, $param_error, $escape)/ge;
s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, $max, $min, $param_error)/ge;
return $str if ($param_error);

# get the args to be interpolated.
my $argsStr = $params->{args} || "";

# Escape any escapes.
$str =~ s#\\#\\\\#g if ($escape); # escape any escapes

my @args = split( /\s*,\s*/, $argsStr );

# fill omitted args with empty strings
Expand Down Expand Up @@ -77,18 +81,7 @@ sub _validate {
return
"<span class=\"foswikiAlert\">Invalid parameter <code>\"$_[0]\"</code>, MAKETEXT rejected.</span>";
}

if ( $_[5] ) {

# Escape any escapes.
my $str = $_[0]; # copy to allow modification
$str =~ s#\\#\\\\#g; # escape any escapes
return "[$str]";
}
else {
return
"[$_[0]]"; # Return the complete bracket parameter without escapes
}
return "[$_[0]]"; # Return the complete bracket parameter without escapes
}

1;
Expand Down

0 comments on commit 619cd7c

Please sign in to comment.