Navigation Menu

Skip to content

Commit

Permalink
Item14324: Fix some unescaped braces in regex
Browse files Browse the repository at this point in the history
  • Loading branch information
gac410 committed Mar 1, 2017
1 parent 5f76c08 commit 61ca6a5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions EditTablePlugin/lib/Foswiki/Plugins/EditTablePlugin.pm
Expand Up @@ -83,7 +83,7 @@ We cannot do table parsing in commonTagsHandler because by then the TML has been
=cut

sub beforeCommonTagsHandler {
return unless $_[0] =~ /%EDIT(?:TABLE|CELL){.*}%/;
return unless $_[0] =~ /%EDIT(?:TABLE|CELL)\{.*\}%/;
Foswiki::Func::writeDebug(
"EditTablePlugin::beforeCommonTagsHandler( $web.$topic )")
if $debug;
Expand All @@ -108,7 +108,7 @@ Calls EditTablePlugin::Core::parseTables for INCLUDEd topics.
=cut

sub commonTagsHandler {
return unless $_[0] =~ /%EDIT(?:TABLE|CELL|TABLESTUB){.*}%/;
return unless $_[0] =~ /%EDIT(?:TABLE|CELL|TABLESTUB)\{.*\}%/;

Foswiki::Func::writeDebug(
"EditTablePlugin::commonTagsHandler( $web.$topic )")
Expand Down
6 changes: 3 additions & 3 deletions WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
Expand Up @@ -289,17 +289,17 @@ sub _processTags {
while ( scalar(@queue) ) {
my $token = shift(@queue);
if ( $token =~ /^\n?%$/s ) {
if ( $token eq '%' && $stackTop =~ /}$/ ) {
if ( $token eq '%' && $stackTop =~ /\}$/ ) {
while ( scalar(@stack)
&& $stackTop !~
/^\n?%(?:~~ )?($Foswiki::regex{tagNameRegex}){.*}$/os )
/^\n?%(?:~~ )?($Foswiki::regex{tagNameRegex})\{.*\}$/os )
{
$stackTop = pop(@stack) . $stackTop;
}
}
if ( $token eq '%'
&& $stackTop =~
m/^(\n?)%(~~ )?($Foswiki::regex{tagNameRegex})({.*})?$/os )
m/^(\n?)%(~~ )?($Foswiki::regex{tagNameRegex})(\{.*\})?$/os )
{
my $nl = $1;
my $glue = $2 || '';
Expand Down
6 changes: 3 additions & 3 deletions core/lib/Foswiki/Render.pm
Expand Up @@ -669,11 +669,11 @@ sub TML2PlainText {
$text =~ s/%META:/%<nop>META:/g;
}
else {
$text =~ s/%META:[A-Z].*?}%//g;
$text =~ s/%META:[A-Z].*?\}%//g;
}

if ( $opts =~ m/expandvar/ ) {
$text =~ s/(\%)(SEARCH){/$1<nop>$2/g; # prevent recursion
$text =~ s/(\%)(SEARCH)\{/$1<nop>$2/g; # prevent recursion
$topicObject = Foswiki::Meta->new( $this->{session} )
unless $topicObject;
$text = $topicObject->expandMacros($text);
Expand All @@ -685,7 +685,7 @@ sub TML2PlainText {
|| '';
$text =~ s/%WIKITOOLNAME%/$wtn/g;
if ( $opts =~ m/showvar/ ) {
$text =~ s/%(\w+({.*?}))%/$1/g; # defuse
$text =~ s/%(\w+({.*?}))%/$1/g; # defuse
}
else {
$text =~ s/%$Foswiki::regex{tagNameRegex}({.*?})?%//g; # remove
Expand Down
6 changes: 3 additions & 3 deletions core/lib/Foswiki/Serialise/Embedded.pm
Expand Up @@ -67,7 +67,7 @@ sub read {

# head meta-data
# NO THIS CANNOT BE /g - TOPICINFO is _only_ valid as the first line!
$text =~ s<^(%META:(TOPICINFO){(.*)}%\n)>
$text =~ s<^(%META:(TOPICINFO)\{(.*)\}%\n)>
<_readMETA($meta, $1, $2, $3, 1)>e;

# WARNING: if the TOPICINFO *looks* valid but has has unrecognisable
Expand Down Expand Up @@ -100,7 +100,7 @@ sub read {
if ( $format !~ /^[\d.]+$/ || $format < 1.1 ) {
require Foswiki::Compatibility;
if (
$text =~ s/^%META:([^{]+){(.*)}%\n/
$text =~ s/^%META:([^{]+)\{(.*)\}%\n/
Foswiki::Compatibility::readSymmetricallyEncodedMETA(
$meta, $1, $2 ); ''/gem
)
Expand All @@ -110,7 +110,7 @@ sub read {
}
else {
if (
$text =~ s<^(%META:([^{]+){(.*)}%\n)>
$text =~ s<^(%META:([^{]+)\{(.*)\}%\n)>
<_readMETA($meta, $1, $2, $3, 0)>gem
)
{
Expand Down

0 comments on commit 61ca6a5

Please sign in to comment.