Permalink
Browse files

Item14605: Escape braces in regular expressions.

Perl 5.27.8 is even less forgiving.
  • Loading branch information...
gac410 committed Jan 21, 2018
1 parent 2ec0a38 commit 1de30cd826b263c5fa74aa38cbada5df89f60b8a
@@ -342,7 +342,7 @@ sub comment {
# Position relative to index'th comment
my $idx = 0;
unless (
$text =~ s((%COMMENT({.*?})?%.*\n))
$text =~ s((%COMMENT(\{.*?\})?%.*\n))
(&_nth($1,\$idx,$position,$index,$output))eg
)
{
@@ -360,7 +360,7 @@ sub comment {

# remove the index'th comment box
my $idx = 0;
$text =~ s/(%COMMENT({.*?})?%)/_remove_nth($1,\$idx,$remove)/eg;
$text =~ s/(%COMMENT(\{.*?\})?%)/_remove_nth($1,\$idx,$remove)/eg;
}

return ( $meta, $text, $position, $output );
@@ -189,10 +189,10 @@ sub _handleHeadFoot {
my ( $text, $rev1, $rev2, $nrev, $maxrev ) = @_;

if ( $rev2 >= $maxrev ) {
$text =~ s/\$next({.*?})//g;
$text =~ s/\$next(\{.*?\})//g;
}
else {
while ( $text =~ m/\$next({(.*?)})/ ) {
while ( $text =~ m/\$next(\{(.*?)\})/ ) {
my $args = $2 || '';

my $newrev1 = $rev2 < $maxrev ? $rev2 + 1 : $rev2;
@@ -211,15 +211,15 @@ sub _handleHeadFoot {
$url
? "<a href='$url' class='foswikiButton'>$newtext</a>"
: $newtext;
$text =~ s/\$next({.*?})/$replace/;
$text =~ s/\$next(\{.*?\})/$replace/;
}
}

if ( $rev1 <= 1 ) {
$text =~ s/\$previous({.*?})//g;
$text =~ s/\$previous(\{.*?\})//g;
}
else {
while ( $text =~ m/\$previous({(.*?)})/ ) {
while ( $text =~ m/\$previous(\{(.*?)\})/ ) {
my $args = $2 || '';

my $newrev2 = $rev1 > 1 ? $rev1 - 1 : 1;
@@ -238,7 +238,7 @@ sub _handleHeadFoot {
$url
? "<a href='$url' class='foswikiButton'>$newtext</a>"
: $newtext;
$text =~ s/\$previous({.*?})/$replace/;
$text =~ s/\$previous(\{.*?\})/$replace/;
}
}

@@ -338,7 +338,7 @@ sub findDependencies {
}
}
else {
while ( $fwcfg =~ m/\$Foswiki::cfg(({[^}]*})+)/g ) {
while ( $fwcfg =~ m/\$Foswiki::cfg((\{[^}]*\})+)/g ) {
push( @{ $deps->{forward}->{$1} }, $keypath );
push( @{ $deps->{reverse}->{$keypath} }, $1 );
}
@@ -446,7 +446,7 @@ sub check_current_value {
$e = $e->[0];

# Expand {x} as $Foswiki::cfg{x}
$e =~ s/(({[^}]+})+)/\$Foswiki::cfg$1/g;
$e =~ s/((\{[^}]+\})+)/\$Foswiki::cfg$1/g;
if ( $e =~ m/\S/ ) {
my $only_if;
eval("\$only_if=$e");
@@ -125,7 +125,7 @@ sub newLeaf {
my ( $class, $val, $type ) = @_;

if ( $type == Foswiki::Infix::Node::NAME
&& $val =~ m/^({[A-Z][A-Z0-9_]*})+$/i )
&& $val =~ m/^(\{[A-Z][A-Z0-9_]*\})+$/i )
{

# config var name, make sure it's accessible.
@@ -104,7 +104,7 @@ use constant OPS => qw (match and eq lc lte not ref d2n gte length lt ob
sub new {
my ( $class, $options ) = @_;

$options->{words} ||= qr/([A-Z:][A-Z0-9_:]*|({[A-Z][A-Z0-9_]*})+)/i;
$options->{words} ||= qr/([A-Z:][A-Z0-9_:]*|(\{[A-Z][A-Z0-9_]*\})+)/i;
$options->{nodeClass} ||= 'Foswiki::Query::Node';
my $this = $class->SUPER::new($options);
foreach my $op ( OPS() ) {

0 comments on commit 1de30cd

Please sign in to comment.