From: <de...@de...> - 2017-04-07 18:33:55
|
Author: HaraldJoerg Date: 2017-04-07 18:33:47 +0000 (Fri, 07 Apr 2017) New Revision: 30318 Trac url: http://develop.twiki.org/trac/changeset/30318 Modified: twiki/trunk/core/lib/TWiki.pm twiki/trunk/core/lib/TWiki/Compatibility.pm twiki/trunk/core/lib/TWiki/Configure/Load.pm twiki/trunk/core/lib/TWiki/Configure/UI.pm twiki/trunk/core/lib/TWiki/Render.pm twiki/trunk/core/lib/TWiki/Search.pm twiki/trunk/core/lib/TWiki/Store.pm twiki/trunk/core/lib/TWiki/Store/SearchAlgorithms/Forking.pm twiki/trunk/core/lib/TWiki/Store/Subversive.pm twiki/trunk/core/lib/TWiki/Templates.pm twiki/trunk/core/lib/TWiki/UI/RDiff.pm Log: Item7797: Escape left braces in regex (core) Modified: twiki/trunk/core/lib/TWiki/Compatibility.pm =================================================================== --- twiki/trunk/core/lib/TWiki/Compatibility.pm 2017-04-07 18:20:37 UTC (rev 30317) +++ twiki/trunk/core/lib/TWiki/Compatibility.pm 2017-04-07 18:33:47 UTC (rev 30318) @@ -284,7 +284,7 @@ my $line = ''; require TWiki::Attrs; foreach $line ( split( /\r?\n/, $atext ) ) { - if( $line =~ /%FILEATTACHMENT{\s"([^"]*)"([^}]*)}%/ ) { + if( $line =~ /%FILEATTACHMENT\{\s"([^"]*)"([^}]*)}%/ ) { my $name = $1; my $values = new TWiki::Attrs( $2 ); $values->{name} = $name; Modified: twiki/trunk/core/lib/TWiki/Configure/Load.pm =================================================================== --- twiki/trunk/core/lib/TWiki/Configure/Load.pm 2017-04-07 18:20:37 UTC (rev 30317) +++ twiki/trunk/core/lib/TWiki/Configure/Load.pm 2017-04-07 18:33:47 UTC (rev 30318) @@ -108,7 +108,7 @@ if (ref($_) eq 'HASH') { expand(\%$_); } else { - s/(\$TWiki::cfg{[A-Za-z0-9{}]+})/eval $1||'undef'/ge; + s/(\$TWiki::cfg\{[A-Za-z0-9{}]+})/eval $1||'undef'/ge; } } } @@ -128,7 +128,7 @@ =cut sub expandValue { - $_[0] =~ s/(\$TWiki::cfg{[A-Za-z0-9{}]+})/eval $1||'undef'/ge; + $_[0] =~ s/(\$TWiki::cfg\{[A-Za-z0-9{}]+})/eval $1||'undef'/ge; } =pod Modified: twiki/trunk/core/lib/TWiki/Configure/UI.pm =================================================================== --- twiki/trunk/core/lib/TWiki/Configure/UI.pm 2017-04-07 18:20:37 UTC (rev 30317) +++ twiki/trunk/core/lib/TWiki/Configure/UI.pm 2017-04-07 18:33:47 UTC (rev 30318) @@ -97,7 +97,7 @@ sub loadChecker { my ($keys, $item) = @_; my $id = $keys; - $id =~ s/}{/::/g; + $id =~ s/}\{/::/g; $id =~ s/[}{]//g; $id =~ s/'//g; $id =~ s/-/_/g; Modified: twiki/trunk/core/lib/TWiki/Render.pm =================================================================== --- twiki/trunk/core/lib/TWiki/Render.pm 2017-04-07 18:20:37 UTC (rev 30317) +++ twiki/trunk/core/lib/TWiki/Render.pm 2017-04-07 18:33:47 UTC (rev 30318) @@ -2067,7 +2067,7 @@ $text =~ s/(})%/$1/g; # ... }% } else { # Remove %MAKETEXT{"..."}% but preserve text: - $text =~ s/%MAKETEXT{ *"?([^"}]*).*?}%/$1/go; # FIXME: Properly resolve params + $text =~ s/%MAKETEXT\{ *"?([^"}]*).*?}%/$1/go; # FIXME: Properly resolve params # Remove nested %VAR1{ ... %VAR2{...}% ...}% by # first adding nesting level to parenthesis, # e.g. "%A{%B{...}%}% ... %C{%D{...}%}%" Modified: twiki/trunk/core/lib/TWiki/Search.pm =================================================================== --- twiki/trunk/core/lib/TWiki/Search.pm 2017-04-07 18:20:37 UTC (rev 30317) +++ twiki/trunk/core/lib/TWiki/Search.pm 2017-04-07 18:33:47 UTC (rev 30318) @@ -556,7 +556,7 @@ # SMELL: the only META tags in a template will be METASEARCH # Why the heck are they being filtered???? - $tmpl =~ s/\%META{.*?}\%//go; # remove %META{'parent'}% + $tmpl =~ s/\%META\{.*?}\%//go; # remove %META{'parent'}% # Split template into 5 sections my ( $tmplHead, $tmplSearch, $tmplTable, $tmplNumber, $tmplTail ) = @@ -922,7 +922,7 @@ } if ( $topic eq $session->{topicName} ) { # defuse SEARCH in current topic to prevent loop - $text =~ s/%SEARCH{.*?}%/SEARCH{...}/go; + $text =~ s/%SEARCH\{.*?}%/SEARCH{...}/go; } my $textInserted; if ( $textArgs =~ /\bencode:(\w+)/ ) { Modified: twiki/trunk/core/lib/TWiki/Store/SearchAlgorithms/Forking.pm =================================================================== --- twiki/trunk/core/lib/TWiki/Store/SearchAlgorithms/Forking.pm 2017-04-07 18:20:37 UTC (rev 30317) +++ twiki/trunk/core/lib/TWiki/Store/SearchAlgorithms/Forking.pm 2017-04-07 18:33:47 UTC (rev 30318) @@ -51,14 +51,14 @@ } if( $options->{casesensitive} ) { - $program =~ s/%CS{(.*?)\|.*?}%/$1/g; + $program =~ s/%CS\{(.*?)\|.*?}%/$1/g; } else { - $program =~ s/%CS{.*?\|(.*?)}%/$1/g; + $program =~ s/%CS\{.*?\|(.*?)}%/$1/g; } if( $options->{files_without_match} ) { - $program =~ s/%DET{.*?\|(.*?)}%/$1/g; + $program =~ s/%DET\{.*?\|(.*?)}%/$1/g; } else { - $program =~ s/%DET{(.*?)\|.*?}%/$1/g; + $program =~ s/%DET\{(.*?)\|.*?}%/$1/g; } if ($options->{wordboundaries} ) { # Item5529: Can't use quotemeta because $searchString may be UTF8 encoded Modified: twiki/trunk/core/lib/TWiki/Store/Subversive.pm =================================================================== --- twiki/trunk/core/lib/TWiki/Store/Subversive.pm 2017-04-07 18:20:37 UTC (rev 30317) +++ twiki/trunk/core/lib/TWiki/Store/Subversive.pm 2017-04-07 18:33:47 UTC (rev 30318) @@ -290,8 +290,8 @@ $program = $TWiki::cfg{RCS}{FgrepCmd}; } - $program =~ s/%CS{(.*?)\|(.*?)}%/$options->{casesensitive}?$1:$2/ge; - $program =~ s/%DET{(.*?)\|(.*?)}%/$options->{files_without_match}?$2:$1/ge; + $program =~ s/%CS\{(.*?)\|(.*?)}%/$options->{casesensitive}?$1:$2/ge; + $program =~ s/%DET\{(.*?)\|(.*?)}%/$options->{files_without_match}?$2:$1/ge; my $sDir = $TWiki::cfg{DataDir}.'/'.$this->{web}.'/'; my $seen = {}; Modified: twiki/trunk/core/lib/TWiki/Store.pm =================================================================== --- twiki/trunk/core/lib/TWiki/Store.pm 2017-04-07 18:20:37 UTC (rev 30317) +++ twiki/trunk/core/lib/TWiki/Store.pm 2017-04-07 18:33:47 UTC (rev 30318) @@ -1405,7 +1405,7 @@ my $format = $STORE_FORMAT_VERSION; # head meta-data - $text =~ s(^%META:TOPICINFO{(.*)}%\r?\n) + $text =~ s(^%META:TOPICINFO\{(.*)}%\r?\n) ($meta->put( 'TOPICINFO', _readKeyValues( $1 ));'')gem; my $ti = $meta->get( 'TOPICINFO' ); Modified: twiki/trunk/core/lib/TWiki/Templates.pm =================================================================== --- twiki/trunk/core/lib/TWiki/Templates.pm 2017-04-07 18:20:37 UTC (rev 30317) +++ twiki/trunk/core/lib/TWiki/Templates.pm 2017-04-07 18:33:47 UTC (rev 30318) @@ -106,7 +106,7 @@ sub _expandTrivialTemplate { my( $this, $text ) = @_; - $text =~ /%TMPL\:P{(.*)}%/; + $text =~ /%TMPL\:P\{(.*)}%/; my $attrs = new TWiki::Attrs( $1 ); # Can't expand context-dependant templates return $text if ( $attrs->{context} ); @@ -181,7 +181,7 @@ $val =~ s/%$p%/$params->{$p}/ge; } } - $val =~ s/%TMPL:P{(.*?)}%/$this->expandTemplate($1)/ge; + $val =~ s/%TMPL:P\{(.*?)}%/$this->expandTemplate($1)/ge; } return $val; @@ -228,12 +228,12 @@ # recursively read template file(s) my $text = _readTemplateFile( $this, $name, $skins, $web ); - while( $text =~ /%TMPL\:INCLUDE{[\s\"]*(.*?)[\"\s]*}%/s ) { - $text =~ s/%TMPL\:INCLUDE{[\s\"]*(.*?)[\"\s]*}%/_readTemplateFile( $this, $1, $skins, $web )/geo; + while( $text =~ /%TMPL\:INCLUDE\{[\s\"]*(.*?)[\"\s]*}%/s ) { + $text =~ s/%TMPL\:INCLUDE\{[\s\"]*(.*?)[\"\s]*}%/_readTemplateFile( $this, $1, $skins, $web )/geo; } # Kill comments, marked by %{ ... }% - $text =~ s/%{.*?}%//sg; + $text =~ s/%\{.*?}%//sg; if( ! ( $text =~ /%TMPL\:/s ) ) { # no template processing @@ -248,7 +248,7 @@ foreach( split( /(%TMPL\:)/, $text ) ) { if( /^(%TMPL\:)$/ ) { $delim = $1; - } elsif( ( /^DEF{[\s\"]*(.*?)[\"\s]*}%(.*)/s ) && ( $1 ) ) { + } elsif( ( /^DEF\{[\s\"]*(.*?)[\"\s]*}%(.*)/s ) && ( $1 ) ) { # handle %TMPL:DEF{key}% if( $key ) { $this->{VARS}->{$key} = $val; @@ -272,7 +272,7 @@ } # handle %TMPL:P{"..."}% recursively - $result =~ s/(%TMPL\:P{.*?}%)/_expandTrivialTemplate( $this, $1)/geo; + $result =~ s/(%TMPL\:P\{.*?}%)/_expandTrivialTemplate( $this, $1)/geo; $result =~ s|^(( {3})+)|"\t" x (length($1)/3)|geom; # leading spaces to tabs return $result; Modified: twiki/trunk/core/lib/TWiki/UI/RDiff.pm =================================================================== --- twiki/trunk/core/lib/TWiki/UI/RDiff.pm 2017-04-07 18:20:37 UTC (rev 30317) +++ twiki/trunk/core/lib/TWiki/UI/RDiff.pm 2017-04-07 18:33:47 UTC (rev 30318) @@ -68,7 +68,7 @@ my( $session, $data, $web, $topic ) = @_; ASSERT($topic) if DEBUG; if ( $data ){ - $data =~ s(^%META:FIELD{(.*)}%.*$) + $data =~ s(^%META:FIELD\{(.*)}%.*$) (_renderAttrs($1,'|*FORM FIELD $title*|$name|$value|'))gem; $data =~ s(^%META:([A-Z]+){(.*)}%$) ('|*META '.$1.'*|'._renderAttrs($2).'|')gem; @@ -436,7 +436,7 @@ my $skin = $session->getSkin(); my $tmpl = $session->templates->readTemplate( 'rdiff', $skin ); - $tmpl =~ s/\%META{.*?}\%//go; # remove %META{'parent'}% + $tmpl =~ s/\%META\{.*?}\%//go; # remove %META{'parent'}% my( $before, $difftmpl, $after, $tail) = split( /%REPEAT%/, $tmpl); Modified: twiki/trunk/core/lib/TWiki.pm =================================================================== --- twiki/trunk/core/lib/TWiki.pm 2017-04-07 18:20:37 UTC (rev 30317) +++ twiki/trunk/core/lib/TWiki.pm 2017-04-07 18:33:47 UTC (rev 30318) @@ -1673,7 +1673,7 @@ foreach my $line (split(/[\n\r]+/, $text)) { # sample line: # | %ICON{help}% | =%<nop>ICON{help}%=, =%<nop>H%= | Help | gif | 16x16 | info | - if( $line =~ / %ICON{[ "']*([^ "'}]+)[^\|]*\|[^\|]*\| *(.*?) *\| *(.*?) *\| *([0-9]+)x([0-9]+)([^\|]*\| *(.*?) *\|)?/ ) { + if( $line =~ / %ICON\{[ "']*([^ "'}]+)[^\|]*\|[^\|]*\| *(.*?) *\| *(.*?) *\| *([0-9]+)x([0-9]+)([^\|]*\| *(.*?) *\|)?/ ) { my $name = $1; $this->{_ICONDATA}->{$name} = { name => $name, @@ -4982,7 +4982,7 @@ $value = '' unless defined $value; } # Block expansion of %URLPARAM in the value to prevent recursion - $value =~ s/%URLPARAM{/%<nop>URLPARAM{/g; + $value =~ s/%URLPARAM\{/%<nop>URLPARAM{/g; return $value; } |