diff --git a/core/lib/Foswiki.pm b/core/lib/Foswiki.pm index 46c7999178..309d9f202e 100644 --- a/core/lib/Foswiki.pm +++ b/core/lib/Foswiki.pm @@ -3782,8 +3782,30 @@ 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(\(\))?/\ > + $text =~ s/\$gt(\(\))?/\>/gs; + + # $amp -> & + $text =~ s/\$amp(\(\))?/\&/gs; # $dollar -> $, done last to avoid creating the above tokens $text =~ s/\$dollar(\(\))?/\$/gs; @@ -3791,21 +3813,6 @@ s/\$((n(?=[^[:alpha:]]|$))|n\(\)|nop|quot|comma|perce?nt|lt|gt|amp)(?:\(\))?/&my 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