Skip to content

Commit

Permalink
Item13893: revert commit 409b0f4
Browse files Browse the repository at this point in the history
MichaelDaum points out this is a bogus fix, and I've obviously misread
my benchmarking results as this is indeed slower.  Leave the unit test
changes as they cover a couple of more cases.
  • Loading branch information
gac410 committed Jan 26, 2016
1 parent 536360c commit 5a48fbc
Showing 1 changed file with 24 additions and 17 deletions.
41 changes: 24 additions & 17 deletions core/lib/Foswiki.pm
Expand Up @@ -3782,30 +3782,37 @@ System.FormatTokens for a full list of supported tokens.
sub expandStandardEscapes {
my $text = shift;

$text =~
s/\$((n(?=[^[:alpha:]]|$))|n\(\)|nop|quot|comma|perce?nt|lt|gt|amp)(?:\(\))?/&mysubst($1)/gse;
# expand '$n()' and $n! to new line
$text =~ s/\$n\(\)/\n/gs;
$text =~ s/\$n(?=[^[:alpha:]]|$)/\n/gs;

# filler, useful for nested search
$text =~ s/\$nop(\(\))?//gs;

# $quot -> "
$text =~ s/\$quot(\(\))?/\"/gs;

# $comma -> ,
$text =~ s/\$comma(\(\))?/,/gs;

# $percent -> %
$text =~ s/\$perce?nt(\(\))?/\%/gs;

# $lt -> <
$text =~ s/\$lt(\(\))?/\</gs;

# $gt -> >
$text =~ s/\$gt(\(\))?/\>/gs;

# $amp -> &
$text =~ s/\$amp(\(\))?/\&/gs;

# $dollar -> $, done last to avoid creating the above tokens
$text =~ s/\$dollar(\(\))?/\$/gs;

return $text;
}

sub mysubst {
return '"' if $_[0] eq 'quot';
return '<' if $_[0] eq 'lt';
return '>' if $_[0] eq 'gt';
return '%' if ( $_[0] eq 'percent' | $_[0] eq 'percnt' );
return ',' if $_[0] eq 'comma';
return '&' if $_[0] eq 'amp';
return '' if $_[0] eq 'nop';
return "\n" if ( $_[0] eq 'n' );

# SMELL. Since $n, the trailing () are required, the regex might match $n()()
# so this requires an exception.
return "\n()" if ( $_[0] eq 'n()' );
}

=begin TML
---++ ObjectMethod webExists( $web ) -> $boolean
Expand Down

0 comments on commit 5a48fbc

Please sign in to comment.