Skip to content

Commit

Permalink
Item13287: remove ALL pointless and/or dangerous /o modifiers from re…
Browse files Browse the repository at this point in the history
…gexes. They have very little performance impact, and in most cases were being used to freeze FW config vars, which is downright dangerous in a persistant environment and for unit tests
  • Loading branch information
Comment committed Mar 1, 2015
1 parent 023e0e5 commit 060fcbc
Show file tree
Hide file tree
Showing 222 changed files with 1,236 additions and 1,228 deletions.
Expand Up @@ -147,7 +147,7 @@ sub _getTemplateFromTemplateExistence {
my ( $templateWeb, $templateTopic ) =
Foswiki::Func::normalizeWebTopicName( $web, $formName );

$templateWeb =~ s/\//\./go;
$templateWeb =~ s/\//\./g;
my $templateName = $templateWeb . '.' . $templateTopic;
$templateName =~ s/Form$//;
$templateName .= $isEditAction ? 'Edit' : 'View';
Expand Down
50 changes: 25 additions & 25 deletions BuildContrib/lib/Foswiki/Contrib/Build.pm
Expand Up @@ -210,7 +210,7 @@ sub new {
my $n = 0;
my $done = 0;
while ( $n <= $#ARGV ) {
if ( $ARGV[$n] =~ /^-/o ) {
if ( $ARGV[$n] =~ m/^-/ ) {
$this->{ $ARGV[$n] } = 1;
}
else {
Expand All @@ -232,10 +232,10 @@ sub new {
#SMELL: Hardcoded project classification
# where the sub-modules live
$this->{libdir} = $libpath;
if ( $this->{project} =~ /Plugin$/ ) {
if ( $this->{project} =~ m/Plugin$/ ) {
$this->{libdir} .= "/$targetProject/Plugins";
}
elsif ( $this->{project} =~ /(Contrib|Skin|AddOn)$/ ) {
elsif ( $this->{project} =~ m/(Contrib|Skin|AddOn)$/ ) {
$this->{libdir} .= "/$targetProject/Contrib";
}

Expand Down Expand Up @@ -270,7 +270,7 @@ sub new {
$badVersion = 1 if ( $version =~ m/\$Date|\$Rev/ );

substr( $version, 0, 0, 'use version 0.77; ' )
if ( $version =~ /version/ );
if ( $version =~ m/version/ );

eval $version if ($version);
eval $release if ($release);
Expand Down Expand Up @@ -359,9 +359,9 @@ sub new {
$rawdeps .=
"$dep->{name},$dep->{version},$dep->{trigger},$dep->{type},$dep->{description}\n";
my $v = $dep->{version};
$v =~ s/&/&amp;/go;
$v =~ s/>/&gt;/go;
$v =~ s/</&lt;/go;
$v =~ s/&/&amp;/g;
$v =~ s/>/&gt;/g;
$v =~ s/</&lt;/g;
my $cells =
CGI::td( { align => 'left' }, $dep->{name} )
. CGI::td( { align => 'left' }, $v )
Expand Down Expand Up @@ -533,7 +533,7 @@ sub _addDependency {
my $b = $dep{version};
$a =~ s/[<>=]//g;
$b =~ s/[<>=]//g;
if ( $a =~ /^[0-9.]+$/ && $b =~ /^[0-9.]+$/ ) {
if ( $a =~ m/^[0-9.]+$/ && $b =~ m/^[0-9.]+$/ ) {
if ( $a < $b ) {
$existing[0]->{version} = $dep{version};
}
Expand All @@ -552,12 +552,12 @@ sub _loadDependenciesFrom {
if ( -f $depsFile ) {
open( PF, '<', $depsFile ) || die 'Failed to open ' . $depsFile;
while ( my $line = <PF> ) {
if ( $line =~ /^\s*$/ || $line =~ /^\s*#/ ) {
if ( $line =~ m/^\s*$/ || $line =~ m/^\s*#/ ) {
}
elsif ( $line =~ /^ONLYIF\s*(\(.*\))\s*$/ ) {
elsif ( $line =~ m/^ONLYIF\s*(\(.*\))\s*$/ ) {
$condition = $1;
}
elsif ( $line =~ m/^(\w+)\s+(\w*)\s*(.*)$/o ) {
elsif ( $line =~ m/^(\w+)\s+(\w*)\s*(.*)$/ ) {
die "Badly formatted ONLYIF" if $1 eq 'ONLYIF';
$this->_addDependency(
name => $1,
Expand All @@ -568,7 +568,7 @@ sub _loadDependenciesFrom {
);
$condition = 1;
}
elsif ( $line =~ m/^([^,]+),([^,]*),\s*(\w*)\s*,\s*(.+)$/o ) {
elsif ( $line =~ m/^([^,]+),([^,]*),\s*(\w*)\s*,\s*(.+)$/ ) {
$this->_addDependency(
name => $1,
version => $2,
Expand Down Expand Up @@ -632,7 +632,7 @@ sub _get_repo_information {
if ( -f $file ) {
push @files, $file;
}
elsif ( $file =~ /\/$/ )
elsif ( $file =~ m/\/$/ )
{ # Directory, create if it does not exist
File::Path::mkpath($file);
}
Expand All @@ -655,7 +655,7 @@ sub _get_repo_information {
my $log = $this->sys_action( @command, @files );
my $getDate = 0;
foreach my $line ( split( "\n", $log ) ) {
if ( $line =~ /^Last Changed Rev: (\d+)/ ) {
if ( $line =~ m/^Last Changed Rev: (\d+)/ ) {
$getDate = 0;
if ( $1 > $max ) {
$max = $1;
Expand All @@ -664,7 +664,7 @@ sub _get_repo_information {
}
elsif ($getDate
&& $line =~
/(?:^Text Last Updated|Last Changed Date): ([\d-]+) ([\d:]+) ([-+\d]+)?/m
m/(?:^Text Last Updated|Last Changed Date): ([\d-]+) ([\d:]+) ([-+\d]+)?/m
)
{
$maxd = Foswiki::Time::parseTime(
Expand All @@ -678,14 +678,14 @@ sub _get_repo_information {
{
@command = qw(git log -1 --pretty=medium --date=iso --);
my $log = $this->sys_action( @command, @files );
if ( $log =~ /^\s+git-svn-id: \S+\@(\d+)\s/m ) {
if ( $log =~ m/^\s+git-svn-id: \S+\@(\d+)\s/m ) {
$max = $1 if $1 > $max;
}
else {
die 'You have un-published changes.'
. ' Please "git svn dcommit"';
}
if ( $log =~ /^Date:\s+([\d-]+) ([\d:]+) ([-+\d]+)?/m ) {
if ( $log =~ m/^Date:\s+([\d-]+) ([\d:]+) ([-+\d]+)?/m ) {
$maxd = Foswiki::Time::parseTime("$1T$2$3");
}
}
Expand Down Expand Up @@ -726,7 +726,7 @@ sub filter_file {
open( $fh, '<', $from ) || die 'No source topic ' . $from . ' for filter';
local $/ = undef;
my $text = <$fh>;
$text = $this->$sub($text) unless $from =~ /Dependency.pm$/;
$text = $this->$sub($text) unless $from =~ m/Dependency.pm$/;
close($fh);

unless ( $this->{-n} ) {
Expand All @@ -744,15 +744,15 @@ sub ask {
my $reply;
local $/ = "\n";

$q .= '?' unless $q =~ /\?\s*$/;
$q .= '?' unless $q =~ m/\?\s*$/;

my $yorn = 'y/n';
if ( defined $default ) {
if ( $default =~ /y/i ) {
if ( $default =~ m/y/i ) {
$default = 'yes';
$yorn = 'Y/n';
}
elsif ( $default =~ /n/i ) {
elsif ( $default =~ m/n/i ) {
$default = 'no';
$yorn = 'y/N';
}
Expand All @@ -763,13 +763,13 @@ sub ask {
print $q. ' [' . $yorn . '] ';

while ( ( $reply = <STDIN> ) !~ /^[yn]/i ) {
if ( $reply =~ /^\s*$/ && defined($default) ) {
if ( $reply =~ m/^\s*$/ && defined($default) ) {
$reply = $default;
last;
}
print "Please answer yes or no\n";
}
return ( $reply =~ /^y/i ) ? 1 : 0;
return ( $reply =~ m/^y/i ) ? 1 : 0;
}

sub prompt {
Expand Down Expand Up @@ -984,7 +984,7 @@ sub filter_txt {
# Item10629: Must preserve version for CompareRevisionAddOnDemoTopic, or nothing to demo
$text =~ s/^(%META:TOPICINFO{.*version=").*?(".*}%)$/${1}1$2/m
unless $from =~ m/CompareRevisionsAddOnDemoTopic.txt$/;
$text =~ s/%\$(\w+)%/&_expand($this,$1)/geo;
$text =~ s/%\$(\w+)%/&_expand($this,$1)/ge;
return $text;
}
);
Expand Down Expand Up @@ -1021,7 +1021,7 @@ sub filter_pm {
$from, $to,
sub {
my ( $this, $text ) = @_;
$text =~ s/\$Rev(:\s*\d+)?\s*\$/\$Rev\: $this->{VERSION} \$/gso;
$text =~ s/\$Rev(:\s*\d+)?\s*\$/\$Rev\: $this->{VERSION} \$/gs;
return $text;
}
);
Expand Down
2 changes: 1 addition & 1 deletion CommentPlugin/lib/Foswiki/Plugins/CommentPlugin.pm
Expand Up @@ -207,7 +207,7 @@ sub _restSave {
# Pre 1.2.0 compatibility
my $html = Foswiki::Validation::addValidationKey( $cgis,
$context, 1 );
$nonce = $1 if ( $html =~ /value=['"]\?(.*?)['"]/ );
$nonce = $1 if ( $html =~ m/value=['"]\?(.*?)['"]/ );
}
$response->pushHeader( 'X-Foswiki-Validation' => $nonce )
if defined $nonce;
Expand Down
2 changes: 1 addition & 1 deletion ConfigurePlugin/lib/Foswiki/Plugins/ConfigurePlugin.pm
Expand Up @@ -85,7 +85,7 @@ sub initPlugin {
map { $_ =~ s/^.*:://; $_ }
grep { defined &{$_} }
map { "Foswiki::Configure::Query::$_" }
grep { $_ =~ /^[a-z]/ }
grep { $_ =~ m/^[a-z]/ }
keys %Foswiki::Configure::Query::;

foreach my $method (@methods) {
Expand Down
2 changes: 1 addition & 1 deletion EmptyPlugin/lib/Foswiki/Plugins/EmptyPlugin.pm
Expand Up @@ -503,7 +503,7 @@ Iterating over blocks for a single tag is easy. For example, to prepend a
line number to every line of every pre block you might use this code:
<verbatim>
foreach my $placeholder ( keys %$map ) {
if( $placeholder =~ /^pre/i ) {
if( $placeholder =~ m/^pre/i ) {
my $n = 1;
$map->{$placeholder}{text} =~ s/^/$n++/gem;
}
Expand Down
6 changes: 3 additions & 3 deletions HistoryPlugin/lib/Foswiki/Plugins/HistoryPlugin.pm
Expand Up @@ -65,7 +65,7 @@ sub _handleHistory {
my $nrev = $params->{nrev} ? $params->{nrev} : 10;

if ($versions) {
$versions =~ /([0-9\-]*)(\.\.)*([0-9\-]*)/;
$versions =~ m/([0-9\-]*)(\.\.)*([0-9\-]*)/;
if ( defined $1 && length $1 ) {
$rev1 = $1;
}
Expand Down Expand Up @@ -191,7 +191,7 @@ sub _handleHeadFoot {
$text =~ s/\$next({.*?})//g;
}
else {
while ( $text =~ /\$next({(.*?)})/ ) {
while ( $text =~ m/\$next({(.*?)})/ ) {
my $args = $2 || '';

my $newrev1 = $rev2 < $maxrev ? $rev2 + 1 : $rev2;
Expand All @@ -218,7 +218,7 @@ sub _handleHeadFoot {
$text =~ s/\$previous({.*?})//g;
}
else {
while ( $text =~ /\$previous({(.*?)})/ ) {
while ( $text =~ m/\$previous({(.*?)})/ ) {
my $args = $2 || '';

my $newrev2 = $rev1 > 1 ? $rev1 - 1 : 1;
Expand Down
8 changes: 4 additions & 4 deletions InterwikiPlugin/lib/Foswiki/Plugins/InterwikiPlugin.pm
Expand Up @@ -144,7 +144,7 @@ sub _link {
$postfix ||= '';

my $upage = $page;
if ( $page =~ /^['"](.*)["']$/ ) {
if ( $page =~ m/^['"](.*)["']$/ ) {
$page = $1;
$upage = Foswiki::urlEncode($1);
}
Expand All @@ -154,9 +154,9 @@ sub _link {
my $tooltip = $interSiteTable{$site}{tooltip};
my $url = $interSiteTable{$site}{url};

#$url .= $page unless ( $url =~ /\$page/ );
#$url .= $page unless ( $url =~ m/\$page/ );

if ( $url =~ /\$page/ ) {
if ( $url =~ m/\$page/ ) {
$url =~ s/\$page/$upage/g;
}
else {
Expand All @@ -168,7 +168,7 @@ sub _link {

# [[...]] or [[...][...]] interwiki link
$text = '';
if ( $postfix =~ /^\]\[([^\]]+)/ ) {
if ( $postfix =~ m/^\]\[([^\]]+)/ ) {
$label = $1;
}
}
Expand Down
7 changes: 4 additions & 3 deletions JQueryPlugin/lib/Foswiki/Form/Rating.pm
Expand Up @@ -53,12 +53,12 @@ sub getOptions {
return $options if $options;
$options = $this->SUPER::getOptions();

if ( $this->{type} =~ /\+values/ ) {
if ( $this->{type} =~ m/\+values/ ) {
$this->{valueMap} = ();
$this->{_options} = ();
my $str;
foreach my $val (@$options) {
if ( $val =~ /^(.*?[^\\])=(.*)$/ ) {
if ( $val =~ m/^(.*?[^\\])=(.*)$/ ) {
$str = $1;
$val = $2;
$str =~ s/\\=/=/g;
Expand All @@ -82,7 +82,8 @@ sub getDataValues {
my @vals = ();

foreach my $val (@$options) {
if ( $this->{type} =~ /\+values/ && defined( $this->{valueMap}{$val} ) )
if ( $this->{type} =~ m/\+values/
&& defined( $this->{valueMap}{$val} ) )
{
push @vals, { $this->{valueMap}{$val} => $val };
}
Expand Down
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Form/Textboxlist.pm
Expand Up @@ -40,7 +40,7 @@ sub renderForEdit {
my @values = @{ $this->SUPER::getOptions() };
my $metadata = '';
if (@values) {
if ( scalar(@values) == 1 && $values[0] =~ /^https?:/ ) {
if ( scalar(@values) == 1 && $values[0] =~ m/^https?:/ ) {
$metadata = "{autocomplete: '$values[0]'}";
}
else {
Expand Down
6 changes: 3 additions & 3 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin.pm
Expand Up @@ -364,7 +364,7 @@ sub handleJQueryIcon {
my $iconClass;

# fontawesome
if ( $iconName =~ /^fa\-/ ) {
if ( $iconName =~ m/^fa\-/ ) {
$iconFormat = '<i class=\'$iconClass\' $iconStyle $iconTitle></i>';
$iconPath = '';
$iconClass = "foswikiIcon jqIcon fa $iconName";
Expand All @@ -391,7 +391,7 @@ sub handleJQueryIcon {
$img =~ s/\$iconStyle/style='$iconStyle'/g if $iconStyle;
$img =~ s/\$iconAlt/alt='$iconAlt' /g if $iconAlt;
$img =~ s/\$iconTitle/title='$iconTitle' /g if $iconTitle;
$img =~ s/\$(iconAlt|iconTitle|iconStyle)//go;
$img =~ s/\$(iconAlt|iconTitle|iconStyle)//g;

return $img;
}
Expand Down Expand Up @@ -431,7 +431,7 @@ sub handleJQueryPlugins {
$summary =~ s/^\s+//;
$summary =~ s/\s+$//;
my $tags = '';
if ( $theFormat =~ /\$tags/ ) {
if ( $theFormat =~ m/\$tags/ ) {
my @lines = ();
my @tags = ();
if ( ref( $plugin->{tags} ) ) {
Expand Down

0 comments on commit 060fcbc

Please sign in to comment.