Skip to content

Commit

Permalink
Item12285: Better fix
Browse files Browse the repository at this point in the history
Don't use references, they are not required.

Sync up the Patch contrib to the newest version.

git-svn-id: http://svn.foswiki.org/trunk@16189 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Dec 11, 2012
1 parent dfb1366 commit 707c599
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions core/lib/Foswiki/Macros/MAKETEXT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ sub MAKETEXT {
$param_error = 0;

# 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)/ge;
$str =~
s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, \$max, \$min, \$param_error, $escape)/ge;
s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, $max, $min, $param_error, $escape)/ge;
return $str if ($param_error);

# get the args to be interpolated.
Expand Down Expand Up @@ -62,25 +62,27 @@ s/~\[(\*,\_(\d+),[^,]+(,([^,]+))?)~\]/ _validate($1, $2, \$max, \$min, \$param_e

sub _validate {

${ $_[2] } = $_[1] if ( $_[1] > ${ $_[2] } ); # Record maximum param number
${ $_[3] } = $_[1] if ( $_[1] < ${ $_[3] } ); # Record minimum param number
#my ( $contents, $number, $max, $min, $param_error ) = @_

$_[2] = $_[1] if ( $_[1] > $_[2] ); # Record maximum param number
$_[3] = $_[1] if ( $_[1] < $_[3] ); # Record minimum param number

if ( $_[1] > 100 ) {
${ $_[4] } = 1; # Set error flag
$_[4] = 1; # Set error flag
return
"<span class=\"foswikiAlert\">Excessive parameter number ${$_[2]}, MAKETEXT rejected.</span>";
"<span class=\"foswikiAlert\">Excessive parameter number $_[2], MAKETEXT rejected.</span>";
}
if ( $_[1] < 1 ) {
${ $_[4] } = 1; # Set error flag
$_[4] = 1; # Set error flag
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
my $str = $_[0]; # copy to allow modification
$str =~ s#\\#\\\\#g; # escape any escapes
return "[$str]";
}
else {
Expand Down

0 comments on commit 707c599

Please sign in to comment.