sub _get_local_filename {
my $self = shift;
my $hash = ($self->id % 100) + 100;
- $hash =~ s/.*(\d\d)$/group.$1/;
+ $hash =~ s/.*(\d\d)$/group.$1/a;
return bz_locations()->{'attachdir'} . "/$hash/attachment." . $self->id;
}
if ($size > Bugzilla->params->{'maxattachmentsize'} * 1024) {
my $attachdir = bz_locations()->{'attachdir'};
my $hash = ($attachid % 100) + 100;
- $hash =~ s/.*(\d\d)$/group.$1/;
+ $hash =~ s/.*(\d\d)$/group.$1/a;
mkdir "$attachdir/$hash", 0770;
chmod 0770, "$attachdir/$hash";
if (ref $data) {
}
# Make sure the alias isn't just a number.
- if ($alias =~ /^\d+$/) {
+ if ($alias =~ /^\d+$/a) {
ThrowUserError("alias_is_numeric", {alias => $alias});
}
# Replace all aliases by their corresponding bug ID.
@bug_ids
- = map { $_ =~ /^(\d+)$/ ? $1 : $invocant->check($_, $type)->id } @bug_ids;
+ = map { $_ =~ /^(\d+)$/a ? $1 : $invocant->check($_, $type)->id } @bug_ids;
$deps_in{$type} = \@bug_ids;
}
return (
lc($uri->authority) eq 'bugs.debian.org'
and
- (($uri->path =~ /bugreport\.cgi$/ and $uri->query_param('bug') =~ m|^\d+$|)
- or $uri->path =~ m|^/\d+$|)
+ (($uri->path =~ /bugreport\.cgi$/ and $uri->query_param('bug') =~ m|^\d+$|a)
+ or $uri->path =~ m|^/\d+$|a)
) ? 1 : 0;
}
# This is the shortest standard URL form for Debian BTS URLs,
# and so we reduce all URLs to this.
- $uri->path =~ m|^/(\d+)$| || $uri->query_param('bug') =~ m|^(\d+)$|;
+ $uri->path =~ m|^/(\d+)$|a || $uri->query_param('bug') =~ m|^(\d+)$|a;
$uri = new URI("http://bugs.debian.org/$1");
return $uri;
# GitHub pull request URLs have only one form:
# https://github.com/USER_OR_TEAM_OR_ORGANIZATION_NAME/REPOSITORY_NAME/pull/111
return (lc($uri->authority) eq 'github.com'
- and $uri->path =~ m!^/[^/]+/[^/]+/(?:issues|pull)/\d+$!) ? 1 : 0;
+ and $uri->path =~ m!^/[^/]+/[^/]+/(?:issues|pull)/\d+$!a) ? 1 : 0;
}
sub _check_value {
# http(s)://code.google.com/p/PROJECT_NAME/issues/detail?id=1234
return (lc($uri->authority) eq 'code.google.com'
and $uri->path =~ m|^/p/[^/]+/issues/detail$|
- and $uri->query_param('id') =~ /^\d+$/) ? 1 : 0;
+ and $uri->query_param('id') =~ /^\d+$/a) ? 1 : 0;
}
sub _check_value {
# JIRA URLs have only one basic form (but the jira is optional):
# https://issues.apache.org/jira/browse/KEY-1234
# http://issues.example.com/browse/KEY-1234
- return ($uri->path =~ m|/browse/[A-Z][A-Z]+-\d+$|) ? 1 : 0;
+ return ($uri->path =~ m|/browse/[A-Z][A-Z]+-\d+$|a) ? 1 : 0;
}
sub _check_value {
# https://bugs.launchpad.net/ubuntu/+bug/1234
# https://launchpad.net/bugs/1234
# All variations end with either "/bugs/1234" or "/+bug/1234"
- return ($uri->authority =~ /launchpad\.net$/ and $uri->path =~ m|bugs?/\d+$|)
+ return ($uri->authority =~ /launchpad\.net$/ and $uri->path =~ m|bugs?/\d+$|a)
? 1
: 0;
}
# This is the shortest standard URL form for Launchpad bugs,
# and so we reduce all URLs to this.
- $uri->path =~ m|bugs?/(\d+)$|;
+ $uri->path =~ m|bugs?/(\d+)$|a;
$uri = new URI("https://launchpad.net/bugs/$1");
return $uri;
# MantisBT URLs look like the following ('bugs' directory is optional):
# http://www.mantisbt.org/bugs/view.php?id=1234
- return ($uri->path_query =~ m|view\.php\?id=\d+$|) ? 1 : 0;
+ return ($uri->path_query =~ m|view\.php\?id=\d+$|a) ? 1 : 0;
}
sub _check_value {
# Trac URLs can look like various things:
# http://dev.mutt.org/trac/ticket/1234
# http://trac.roundcube.net/ticket/1484130
- return ($uri->path =~ m|/ticket/\d+$|) ? 1 : 0;
+ return ($uri->path =~ m|/ticket/\d+$|a) ? 1 : 0;
}
sub _check_value {
# Remove the Boolean Charts for standard query.cgi fields
# They are listed in the query URL already
- next if $key =~ /^(field|type|value)(-\d+){3}$/;
+ next if $key =~ /^(field|type|value)(-\d+){3}$/a;
my $esc_key = url_quote($key);
# Custom Search stuff is empty if it's "noop". We also keep around
# the old Boolean Chart syntax for backwards-compatibility.
- if ( ($param =~ /\d-\d-\d/ || $param =~ /^[[:alpha:]]\d+$/)
+ if ( ($param =~ /\d-\d-\d/a || $param =~ /^[[:alpha:]]\d+$/a)
&& defined $self->param($param)
&& $self->param($param) eq 'noop')
{
# Any "join" for custom search that's an AND can be removed, because
# that's the default.
- if (($param =~ /^j\d+$/ || $param eq 'j_top') && $self->param($param) eq 'AND')
+ if (($param =~ /^j\d+$/a || $param eq 'j_top') && $self->param($param) eq 'AND')
{
$self->delete($param);
}
# In this circumstance we run quotemeta first because we need to
# insert an active regex meta-character afterward.
$regex = quotemeta($attach_base);
- $regex =~ s/\\\%bugid\\\%/\\d+/;
+ $regex =~ s/\\\%bugid\\\%/(?a:\\d+)/;
}
$regex = "^$regex";
return ($self->url =~ $regex) ? 1 : 0;
foreach my $param ($cgi->param()) {
# Store all the lines
- if ($param =~ /^line(\d+)$/) {
+ if ($param =~ /^line(\d+)$/a) {
foreach my $series_id ($cgi->param($param)) {
detaint_natural($series_id) || ThrowCodeError("invalid_series_id");
my $series = new Bugzilla::Series($series_id);
}
# Store all the labels
- if ($param =~ /^label(\d+)$/) {
+ if ($param =~ /^label(\d+)$/a) {
$self->{'labels'}[$1] = $cgi->param($param);
}
}
and ThrowUserError('comment_tag_too_short', {tag => $tag});
length($tag) > MAX_COMMENT_TAG_LENGTH
and ThrowUserError('comment_tag_too_long', {tag => $tag});
- $tag =~ /^[\w\d\._-]+$/ or ThrowUserError('comment_tag_invalid', {tag => $tag});
+ $tag =~ /^[\w\._-]+$/ or ThrowUserError('comment_tag_invalid', {tag => $tag});
return $tag;
}
# Fall back to port 443 if for some reason getservbyname() fails.
my $port = getservbyname('https', 'tcp') || 443;
- if ($host =~ /^(.+):(\d+)$/) {
+ if ($host =~ /^(.+):(\d+)$/a) {
$host = $1;
$port = $2;
}
sub check_notification {
my $option = shift;
my @current_version
- = (BUGZILLA_VERSION =~ m/^(\d+)\.(\d+)(?:(rc|\.)(\d+))?\+?$/);
+ = (BUGZILLA_VERSION =~ m/^(\d+)\.(\d+)(?:(rc|\.)(\d+))?\+?$/a);
if ($current_version[1] % 2 && $option eq 'stable_branch_release') {
return
"You are currently running a development snapshot, and so your "
# Oracle doesn't have LIMIT, so if we find the LIMIT comment, wrap the
# query with "SELECT * FROM (...) WHERE rownum < $limit"
- my ($limit, $offset) = ($part =~ m{/\* LIMIT (\d*) (\d*) \*/}o);
+ my ($limit, $offset) = ($part =~ m{/\* LIMIT (\d*) (\d*) \*/}ao);
push @result, $part;
while (@parts) {
$nonstring =~ s/\bAS\b//ig;
# Look for a LIMIT clause
- ($limit) = ($nonstring =~ m(/\* LIMIT (\d*) \*/)o);
+ ($limit) = ($nonstring =~ m(/\* LIMIT (\d*) \*/)ao);
if (!length($string)) {
push @result, EMPTY_STRING;
my $self = shift;
my ($db) = @_;
my $server_version = $self->SUPER::bz_check_server_version(@_);
- my ($major_version, $minor_version) = $server_version =~ /^0*(\d+)\.0*(\d+)/;
+ my ($major_version, $minor_version) = $server_version =~ /^0*(\d+)\.0*(\d+)/a;
# Pg 9.0 requires DBD::Pg 2.17.2 in order to properly read bytea values.
# Pg 9.2 requires DBD::Pg 2.19.3 as spclocation no longer exists.
}
else {
my $name = require $config_file;
- if ($name =~ /^\d+$/) {
+ if ($name =~ /^\d+$/a) {
ThrowCodeError('extension_must_return_name',
{extension => $config_file, returned => $name});
}
}
else {
my $name = require $extension_file;
- if ($name =~ /^\d+$/) {
+ if ($name =~ /^\d+$/a) {
ThrowCodeError('extension_must_return_name',
{extension => $extension_file, returned => $name});
}
my $match_status
= Bugzilla::User::match_field(
- {'^requestee(_type)?-(\d+)$' => {'type' => 'multi'},},
+ {'(?a:^requestee(_type)?-(\d+)$)' => {'type' => 'multi'},},
undef, $skip);
$vars->{'match_field'} = 'requestee';
}
# Extract a list of flag type IDs from field names.
- my @flagtype_ids = map(/^flag_type-(\d+)$/ ? $1 : (), $cgi->param());
+ my @flagtype_ids = map(/^flag_type-(\d+)$/a ? $1 : (), $cgi->param());
@flagtype_ids = grep($cgi->param("flag_type-$_") ne 'X', @flagtype_ids);
# Extract a list of existing flag IDs.
- my @flag_ids = map(/^flag-(\d+)$/ ? $1 : (), $cgi->param());
+ my @flag_ids = map(/^flag-(\d+)$/a ? $1 : (), $cgi->param());
return ([], []) unless (scalar(@flagtype_ids) || scalar(@flag_ids));
my $match_status
= Bugzilla::User::match_field(
- {'^requestee(_type)?-(\d+)$' => {'type' => 'multi'},},
+ {'(?a:^requestee(_type)?-(\d+)$)' => {'type' => 'multi'},},
undef, $skip);
$vars->{'match_field'} = 'requestee';
}
# Extract a list of flag type IDs from field names.
- my @flagtype_ids = map(/^flag_type-(\d+)$/ ? $1 : (), $cgi->param());
+ my @flagtype_ids = map(/^flag_type-(\d+)$/a ? $1 : (), $cgi->param());
my (@new_flags, @flags);
my $buffer = "";
foreach my $line (split(/\n/, $desc)) {
$line =~ s/\s+$//g; # Trim trailing whitespace.
- if ($line =~ /^------- Additional Comments From ([^\s]+)\s+(\d.+\d)\s+-------$/)
+ if ($line =~ /^------- Additional Comments From ([^\s]+)\s+((?a:\d.+\d))\s+-------$/)
{
my $name = $1;
my $date = str2time($2);
# check if the value already exists
my $sortkey = substr($value, 1);
- if ($sortkey !~ /^\d+$/) {
+ if ($sortkey !~ /^\d+$/a) {
$sortkey = 0;
}
else {
foreach $key (keys(%dupes)) {
$dupes{$key}
- =~ /^.*\*\*\* This bug has been marked as a duplicate of (\d+) \*\*\*$/ms;
+ =~ /^.*\*\*\* This bug has been marked as a duplicate of (\d+) \*\*\*$/ams;
$dupes{$key} = $1;
$dbh->do("INSERT INTO duplicates VALUES(?, ?)", undef, $dupes{$key}, $key);
my @lines = <$in>;
while (my $line = shift @lines) {
- if ($line =~ /^(\d+\|.*)/) {
+ if ($line =~ /^(\d+\|.*)/a) {
my @numbers = split(/\||\r/, $1);
# Only take the first line for each date; it was possible to
# If no rows are affected, $dbh->do returns 0E0 instead of 0.
print "$rows flags had an illegal modification date. Fixed!\n"
- if ($rows =~ /^\d+$/);
+ if ($rows =~ /^\d+$/a);
}
sub _add_visiblity_value_to_value_tables {
foreach my $id (@comment_ids) {
$count++;
my $text = $comments{$id};
- next if $text !~ /^\Q$string\E(\d+)/;
+ next if $text !~ /^\Q$string\E(\d+)/a;
my $attachment_id = $1;
my @lines = split("\n", $text);
if ($type == CMT_ATTACHMENT_CREATED) {
@declared_fields = map uc, (split /\||\r/, $1);
print OUT "# fields: ", join('|', @out_fields), "\n";
}
- elsif (/^(\d+\|.*)/) {
+ elsif (/^(\d+\|.*)/a) {
my @data = split(/\||\r/, $1);
my %data;
if (@data == @declared_fields) {
# If we come here, then the version is not a valid one.
# We try to sanitize it.
- if ($vnum =~ /^((\d+)(\.\d+)*)/) {
+ if ($vnum =~ /^((\d+)(\.\d+)*)/a) {
$vnum = $1;
}
}
foreach my $file_set (@$file_sets) {
my $file = shift @$file_set;
my $name = require $file;
- if ($name =~ /^\d+$/) {
+ if ($name =~ /^\d+$/a) {
die install_string('extension_must_return_name',
{file => $file, returned => $name});
}
my @qlanguages;
my @languages;
foreach (split /,/, $accept_language) {
- if (m/([A-Za-z\-]+)(?:;q=(\d(?:\.\d+)))?/) {
+ if (m/([A-Za-z\-]+)(?:;q=(\d(?:\.\d+)))?/a) {
my $lang = $1;
my $qvalue = $2;
$qvalue = 1 if not defined $qvalue;
# Keep only the primary error line and drop any stack trace frames.
($message) = split /\n/, $message, 2;
- $message =~ s/\s+at\s+\S+\s+line\s+\d+\.?\s*$//s;
+ $message =~ s/\s+at\s+\S+\s+line\s+(?a:\d+)\.?\s*$//s;
$message =~ s/\s+called\s+at\s+.*$//s;
$message =~ s/\s+/ /g;
$message =~ s/^\s+|\s+$//g;
$sitespec = "-$path$sitespec";
}
- if ($sitespec =~ s/^([^:\/]+):(\d+)/$1/) { # Remove port number, to relocate
+ if ($sitespec =~ s/^([^:\/]+):(\d+)/$1/a) { # Remove port number, to relocate
$sitespec = "-$2$sitespec"; # Put the port number back in, before the '@'
}
$sitespec = "-$path$sitespec";
}
- if ($sitespec =~ s/^([^:\/]+):(\d+)/$1/) { # Remove port number, to relocate
+ if ($sitespec =~ s/^([^:\/]+):(\d+)/$1/a) { # Remove port number, to relocate
$sitespec = "-$2$sitespec"; # Put the port number back in, before the '@'
}
$self->debug("Reading Project: $directory");
# Sometimes other files get into gnats directories.
- @files = grep { basename($_) =~ /^\d+$/ } @files;
+ @files = grep { basename($_) =~ /^\d+$/a } @files;
my @bugs;
my $count = 1;
my $total = scalar @files;
# is longer than 32 characters, pull out the first thing that looks
# like a version number.
elsif (length($value) > LONG_VERSION_LENGTH) {
- $value =~ s/^.+?\b(\d[\w\.]+)\b.+$/$1/;
+ $value =~ s/^.+?\b((?a:\d)[\w\.]+)\b.+$/$1/;
}
}
# regexp verifies one or more digits, optionally followed by a period and
# zero or more digits, OR we have a period followed by one or more digits
# (allow negatives, though, so people can back out errors in time reporting)
- if ($time !~ /^-?(?:\d+(?:\.\d*)?|\.\d+)$/) {
+ if ($time !~ /^-?(?:\d+(?:\.\d*)?|\.\d+)$/a) {
ThrowUserError("number_not_numeric", {field => $field, num => "$time"});
}
# If it looks like we were seeded with a 32-bit integer, warn the
# user that they are making a dangerous, easily-crackable mistake.
- elsif (length($seed) <= 10 and $seed =~ /^\d+$/) {
+ elsif (length($seed) <= 10 and $seed =~ /^\d+$/a) {
warn "RNG seeded with a 32-bit integer, this is easy to crack";
}
}
\d+
)?
$
-/x;
+ /ax;
# If you specify a search type in the boolean charts, this describes
# which operator maps to which internal function here.
# chfieldto is supposed to be a relative date or a date of the form
# YYYY-MM-DD, i.e. without the time appended to it. We append the
# time ourselves so that the end date is correctly taken into account.
- $date_to .= ' 23:59:59' if $date_to =~ /^\d{4}-\d{1,2}-\d{1,2}$/;
+ $date_to .= ' 23:59:59' if $date_to =~ /^\d{4}-\d{1,2}-\d{1,2}$/a;
my $join_clause = new Bugzilla::Search::Clause('OR');
my ($self) = @_;
my $params = $self->_params;
- my @email_params = grep { $_ =~ /^email\d+$/ } keys %$params;
+ my @email_params = grep { $_ =~ /^email\d+$/a } keys %$params;
my $clause = new Bugzilla::Search::Clause();
foreach my $param (@email_params) {
- $param =~ /(\d+)$/;
+ $param =~ /(\d+)$/a;
my $id = $1;
my $email = trim($params->{"email$id"});
next if !$email;
my $params = $self->_params;
my @param_list = keys %$params;
- my @all_field_params = grep {/^field-?\d+/} @param_list;
- my @chart_ids = map { /^field(-?\d+)/; $1 } @all_field_params;
+ my @all_field_params = grep {/^field-?\d+/a} @param_list;
+ my @chart_ids = map { /^field(-?\d+)/a; $1 } @all_field_params;
@chart_ids = sort { $a <=> $b } uniq @chart_ids;
my $clause = new Bugzilla::Search::Clause();
foreach my $chart_id (@chart_ids) {
- my @all_and = grep {/^field$chart_id-\d+/} @param_list;
- my @and_ids = map { /^field$chart_id-(\d+)/; $1 } @all_and;
+ my @all_and = grep {/^field$chart_id-\d+/a} @param_list;
+ my @and_ids = map { /^field$chart_id-(\d+)/a; $1 } @all_and;
@and_ids = sort { $a <=> $b } uniq @and_ids;
my $and_clause = new Bugzilla::Search::Clause();
foreach my $and_id (@and_ids) {
- my @all_or = grep {/^field$chart_id-$and_id-\d+/} @param_list;
- my @or_ids = map { /^field$chart_id-$and_id-(\d+)/; $1 } @all_or;
+ my @all_or = grep {/^field$chart_id-$and_id-\d+/a} @param_list;
+ my @or_ids = map { /^field$chart_id-$and_id-(\d+)/a; $1 } @all_or;
@or_ids = sort { $a <=> $b } uniq @or_ids;
my $or_clause = new Bugzilla::Search::Clause('OR');
my $params = $self->_params;
my @param_list = keys %$params;
- my @field_params = grep {/^f\d+$/} @param_list;
- my @field_ids = map { /(\d+)/; $1 } @field_params;
+ my @field_params = grep {/^f\d+$/a} @param_list;
+ my @field_ids = map { /(\d+)/a; $1 } @field_params;
@field_ids = sort { $a <=> $b } @field_ids;
return @field_ids;
}
my $value = $args->{value};
my $dbh = Bugzilla->dbh;
- return if $value !~ /^(?:[\+\-]?\d+[hdwmy]s?|now)$/i;
+ return if $value !~ /^(?:[\+\-]?\d+[hdwmy]s?|now)$/ai;
$value = SqlifyDate($value);
return sprintf("%4d-%02d-%02d 00:00:00", $year + 1900, $month + 1, $mday);
}
- if ($str =~ /^(-|\+)?(\d+)([hdwmy])(s?)$/i) { # relative date
+ if ($str =~ /^(-|\+)?(\d+)([hdwmy])(s?)$/ai) { # relative date
my ($sign, $amount, $unit, $startof, $date) = ($1, $2, lc $3, lc $4, time);
my ($sec, $min, $hour, $mday, $month, $year, $wday) = localtime($date);
if ($sign && $sign eq '+') { $amount = -$amount; }
my ($word, $negate) = @_;
# P1-5 Syntax
- if ($word =~ m/^P(\d+)(?:-(\d+))?$/i) {
+ if ($word =~ m/^P(\d+)(?:-(\d+))?$/ai) {
my ($p_start, $p_end) = ($1, $2);
my $legal_priorities = get_legal_field_values('priority');
$query =~ s/\b$field=\Q$old\E\b/$field=$new/gi;
# Fix boolean charts.
- while ($query =~ /\bfield(\d+-\d+-\d+)=\Q$field\E\b/gi) {
+ while ($query =~ /\bfield(?a:(\d+-\d+-\d+))=\Q$field\E\b/gi) {
my $chart_id = $1;
# Note that this won't handle lists or substrings inside of
# so we do not allow it to happen. We only do this for logged-in users.
$var =~ s/\\/\x{FF3C}/g if Bugzilla->user->id;
$var =~ s/\"/\"\"/g;
- if ($var !~ /^-?(\d+\.)?\d*$/) {
+ if ($var !~ /^-?(\d+\.)?\d*$/a) {
$var = "\"$var\"";
}
return $var;
}
my $version = BUGZILLA_VERSION;
- $version =~ /^(\d+)\.(\d+)/;
+ $version =~ /^(\d+)\.(\d+)/a;
if ($2 % 2 == 1) {
# second number is odd; development version
# On which branch is the current installation running?
my @current_version
- = (BUGZILLA_VERSION =~ m/^(\d+)\.(\d+)(?:(rc|\.)(\d+))?\+?$/);
+ = (BUGZILLA_VERSION =~ m/^(\d+)\.(\d+)(?:(rc|\.)(\d+))?\+?$/a);
my @release;
if (Bugzilla->params->{'upgrade_notification'} eq 'development_snapshot') {
# Only notify the administrator if the latest version available
# is newer than the current one.
my @new_version
- = ($release[0]->{'latest_ver'} =~ m/^(\d+)\.(\d+)(?:(rc|\.)(\d+))?\+?$/);
+ = ($release[0]->{'latest_ver'} =~ m/^(\d+)\.(\d+)(?:(rc|\.)(\d+))?\+?$/a);
# We convert release candidates 'rc' to integers (rc ? 0 : 1) in order
# to compare versions easily.
# Go through the array, and turn items into group objects
my @groups = ();
foreach my $value (@{$changes->{$key}}) {
- my $type = $value =~ /^\d+$/ ? 'id' : 'name';
+ my $type = $value =~ /^\d+$/a ? 'id' : 'name';
my $group = Bugzilla::Group->new({$type => $value});
if (!$group || !$user->can_bless($group->id)) {
# The field is a requestee field; in order for its name
# to show up correctly on the confirmation page, we need
# to find out the name of its flag type.
- if ($field_name =~ /^requestee(_type)?-(\d+)$/) {
+ if ($field_name =~ /^requestee(_type)?-(\d+)$/a) {
my $flag_type;
if ($1) {
require Bugzilla::FlagType;
if ($complexity_level eq 'letters_numbers_specialchars') {
return 'password_not_complex'
if ($password !~ /[[:alpha:]]/
- || $password !~ /\d/
+ || $password !~ /\d/a
|| $password !~ /[[:punct:]]/);
}
elsif ($complexity_level eq 'letters_numbers') {
return 'password_not_complex'
if ($password !~ /[[:lower:]]/
|| $password !~ /[[:upper:]]/
- || $password !~ /\d/);
+ || $password !~ /\d/a);
}
elsif ($complexity_level eq 'mixed_letters') {
return 'password_not_complex'
my $ip = shift;
return unless defined $ip;
- my @octets = $ip =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
+ my @octets = $ip =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/a;
return unless scalar(@octets) == 4;
foreach my $octet (@octets) {
- return unless ($octet >= 0 && $octet <= 255 && $octet !~ /^0\d{1,2}$/);
+ return unless ($octet >= 0 && $octet <= 255 && $octet !~ /^0\d{1,2}$/a);
}
# The IP address is valid and can now be detainted.
# If $format is not set, try to guess the correct date format.
if (!$format) {
if (!ref $date
- && $date =~ /^(\d{4})[-\.](\d{2})[-\.](\d{2}) (\d{2}):(\d{2})(:(\d{2}))?$/)
+ && $date =~ /^(\d{4})[-\.](\d{2})[-\.](\d{2}) (\d{2}):(\d{2})(:(\d{2}))?$/a)
{
my $sec = $7;
if (defined $sec) {
my @time;
# Most dates will be in this format, avoid strptime's generic parser
- if ($date =~ /^(\d{4})[\.-](\d{2})[\.-](\d{2})(?: (\d{2}):(\d{2}):(\d{2}))?$/) {
+ if ($date =~ /^(\d{4})[\.-](\d{2})[\.-](\d{2})(?: (\d{2}):(\d{2}):(\d{2}))?$/a) {
@time = ($6, $5, $4, $3, $2 - 1, $1 - 1900, undef);
}
else {
if ($ts) {
$date2 = time2str("%Y-%m-%d", $ts);
- $date =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/;
- $date2 =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/;
+ $date =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/a;
+ $date2 =~ s/(\d+)-0*(\d+?)-0*(\d+?)/$1-$2-$3/a;
}
my $ret = ($ts && $date eq $date2);
return $ret ? 1 : 0;
my $ts = str2time($time);
if ($ts) {
$time2 = time2str("%H:%M:%S", $ts);
- if ($time =~ /^(\d{1,2}):(\d\d)(?::(\d\d))?$/) {
+ if ($time =~ /^(\d{1,2}):(\d\d)(?::(\d\d))?$/a) {
$time = sprintf("%02d:%02d:%02d", $1, $2, $3 || 0);
}
}
my ($a, $b) = @_;
# Remove leading zeroes - Bug 344661
- $a =~ s/^0*(\d.+)/$1/;
- $b =~ s/^0*(\d.+)/$1/;
+ $a =~ s/^0*(\d.+)/$1/a;
+ $b =~ s/^0*(\d.+)/$1/a;
- my @A = ($a =~ /([-.]|\d+|[^-.\d]+)/g);
- my @B = ($b =~ /([-.]|\d+|[^-.\d]+)/g);
+ my @A = ($a =~ /([-.]|\d+|[^-.\d]+)/ag);
+ my @B = ($b =~ /([-.]|\d+|[^-.\d]+)/ag);
my ($A, $B);
while (@A and @B) {
elsif ($B eq '.') {
return 1;
}
- elsif ($A =~ /^\d+$/ and $B =~ /^\d+$/) {
+ elsif ($A =~ /^\d+$/a and $B =~ /^\d+$/a) {
if ($A =~ /^0/ || $B =~ /^0/) {
return $A cmp $B if $A cmp $B;
}
# Cache permissions for bugs. This highly reduces the number of calls to the DB.
# visible_bugs() is only able to handle bug IDs, so we have to skip aliases.
- my @int = grep { $_ =~ /^\d+$/ } @$ids;
+ my @int = grep { $_ =~ /^\d+$/a } @$ids;
Bugzilla->user->visible_bugs(\@int);
foreach my $bug_id (@$ids) {
my %options = (fields => ['bug_id']);
# Find the highest custom field id
- my @field_ids = grep(/^f(\d+)$/, keys %$match_params);
+ my @field_ids = grep(/^f(\d+)$/a, keys %$match_params);
my $last_field_id = @field_ids ? max @field_ids + 1 : 1;
# Do special search types for certain fields.
my @accept_types = split /,/, $self->cgi->http('accept') || '';
my $order = 0;
for my $accept_type (@accept_types) {
- my ($weight) = ($accept_type =~ /q=(\d\.\d+|\d+)/);
+ my ($weight) = ($accept_type =~ /q=(\d\.\d+|\d+)/a);
my ($name) = ($accept_type =~ m#(\S+/[^;]+)#);
next unless $name;
push @prefs, {name => $name, order => $order++};
params => sub {
my $value = $_[0];
my $param = 'names';
- $param = 'ids' if $value =~ /^\d+$/;
+ $param = 'ids' if $value =~ /^\d+$/a;
return {$param => [$_[0]]};
}
}
sub _rest_resources {
return [
# bug-id
- qr{^/bug_user_last_visit/(\d+)$},
+ qr{^/bug_user_last_visit/(\d+)$}a,
{
GET => {
method => 'get',
GET => {
method => 'get',
params => sub {
- my $param = $_[0] =~ /^\d+$/ ? 'ids' : 'names';
+ my $param = $_[0] =~ /^\d+$/a ? 'ids' : 'names';
return {$param => [$_[0]]};
}
}
PUT => {
method => 'update',
params => sub {
- my $param = $_[0] =~ /^\d+$/ ? 'ids' : 'names';
+ my $param = $_[0] =~ /^\d+$/a ? 'ids' : 'names';
return {$param => [$_[0]]};
}
}
PUT => {
method => 'update',
params => sub {
- my $param = $_[0] =~ /^\d+$/ ? 'ids' : 'names';
+ my $param = $_[0] =~ /^\d+$/a ? 'ids' : 'names';
return {$param => [$_[0]]};
}
}
GET => {
method => 'get',
params => sub {
- my $param = $_[0] =~ /^\d+$/ ? 'ids' : 'names';
+ my $param = $_[0] =~ /^\d+$/a ? 'ids' : 'names';
return {$param => [$_[0]]};
}
},
PUT => {
method => 'update',
params => sub {
- my $param = $_[0] =~ /^\d+$/ ? 'ids' : 'names';
+ my $param = $_[0] =~ /^\d+$/a ? 'ids' : 'names';
return {$param => [$_[0]]};
}
}
GET => {
method => 'get',
params => sub {
- my $param = $_[0] =~ /^\d+$/ ? 'ids' : 'names';
+ my $param = $_[0] =~ /^\d+$/a ? 'ids' : 'names';
return {$param => [$_[0]]};
}
},
PUT => {
method => 'update',
params => sub {
- my $param = $_[0] =~ /^\d+$/ ? 'ids' : 'names';
+ my $param = $_[0] =~ /^\d+$/a ? 'ids' : 'names';
return {$param => [$_[0]]};
}
}
# and order by, since relevance only exists when doing a fulltext search.
my $fulltext = 0;
if ($cgi->param('content')) { $fulltext = 1 }
-my @charts = map(/^field(\d-\d-\d)$/ ? $1 : (), $cgi->param());
+my @charts = map(/^field(\d-\d-\d)$/a ? $1 : (), $cgi->param());
foreach my $chart (@charts) {
if ($cgi->param("field$chart") eq 'content' && $cgi->param("value$chart")) {
$fulltext = 1;
# Process certain values further (i.e. date format conversion).
if ($bug->{'changeddate'}) {
$bug->{'changeddate'}
- =~ s/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/$1-$2-$3 $4:$5:$6/;
+ =~ s/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/$1-$2-$3 $4:$5:$6/a;
$bug->{'changedtime'} = $bug->{'changeddate'}; # for iCalendar and Atom
$bug->{'changeddate'} = DiffDate($bug->{'changeddate'});
# encode it in the name, as "action-<action>". Some params even contain the
# series_id they apply to (e.g. subscribe, unsubscribe).
my @actions = grep(/^action-/, $cgi->param());
-if ($actions[0] && $actions[0] =~ /^action-([^\d]+)(\d*)$/) {
+if ($actions[0] && $actions[0] =~ /^action-(?a:([^\d]+)(\d*))$/) {
$action = $1;
$series_id = $2 if $2;
}
# Find any selected series and return either the first or all of them.
sub getAndValidateSeriesIDs {
- my @series_ids = grep(/^\d+$/, $cgi->param("name"));
+ my @series_ids = grep(/^\d+$/a, $cgi->param("name"));
return wantarray ? @series_ids : $series_ids[0];
}
# Return a list of IDs of all the lines selected in the UI.
sub getSelectedLines {
- my @ids = map { /^select(\d+)$/ ? $1 : () } $cgi->param();
+ my @ids = map { /^select(\d+)$/a ? $1 : () } $cgi->param();
return @ids;
}
# In MySQL, decimal cols can be too long.
my $col_type = $col_info->{TYPE};
- $col_type =~ /decimal\((\d+),(\d+)\)/;
+ $col_type =~ /decimal\((\d+),(\d+)\)/a;
my ($precision, $decimals) = ($1, $2);
# If it's longer than precision + decimal point
if (ref $_ eq 'HASH' && keys %$_) {
@results = @{$class->match($_)};
}
- elsif (m/^\d+$/) {
+ elsif (m/^\d+$/a) {
@results = ($class->new($_));
}
elsif (m/\w/i && grep { $_ eq 'name' } ($class->_get_db_columns)) {
# Make sure accounts were specified on the command line and exist.
my $old = $ARGV[0] || die "You must specify an old user account.\n";
my $old_id;
-if ($old =~ /^id:(\d+)$/) {
+if ($old =~ /^id:(\d+)$/a) {
# As the old user account may be a deleted one, we don't
# check whether this user ID is valid or not.
my $new = $ARGV[1] || die "You must specify a new user account.\n";
my $new_id;
-if ($new =~ /^id:(\d+)$/) {
+if ($new =~ /^id:(\d+)$/a) {
$new_id = $1;
# Make sure this user ID exists.
my $changer = $ARGV[1];
# Validate the bug number.
-if (!($bugnum =~ /^(\d+)$/)) {
+if (!($bugnum =~ /^(\d+)$/a)) {
say STDERR "Bug number \"$bugnum\" not numeric.";
usage();
}
my @now_na = ();
my @now_mandatory = ();
foreach my $f ($cgi->param()) {
- if ($f =~ /^membercontrol_(\d+)$/) {
+ if ($f =~ /^membercontrol_(\d+)$/a) {
my $id = $1;
if ($cgi->param($f) == CONTROLMAPNA) {
push @now_na, $id;
{mail => $input_email, fields => \%fields});
my $summary = $input_email->header('Subject');
- if ($summary =~ /\[\S+ (\d+)\](.*)/i) {
+ if ($summary =~ /\[\S+ (?a:(\d+))\](.*)/i) {
$fields{'bug_id'} = $1;
$summary = trim($2);
}
my $subject = $args->{mail}->header('Subject');
# Correctly extract the bug ID from email subjects of the form [Bug comp/NNN].
- if ($subject =~ /\[.*(\d+)\].*/) {
+ if ($subject =~ /\[.*(\d+)\].*/a) {
$args->{fields}->{bug_id} = $1;
}
}
# BitBucket issues have the form of
# bitbucket.org/user/project/issue/1234
return (lc($uri->authority) eq "bitbucket.org"
- && $uri->path =~ m|[^/]+/[^/]+/issue/\d+|i) ? 1 : 0;
+ && $uri->path =~ m|[^/]+/[^/]+/issue/\d+|ai) ? 1 : 0;
}
sub _check_value {
my $uri = $class->SUPER::_check_value(@_);
- my ($path) = $uri->path =~ m|([^/]+/[^/]+/issue/\d+)|i;
+ my ($path) = $uri->path =~ m|([^/]+/[^/]+/issue/\d+)|ai;
$uri = new URI("https://bitbucket.org/$path");
return $uri;
# https://bugs.php.net/bug.php?id=1234
return (lc($uri->authority) eq 'bugs.php.net'
and $uri->path =~ m|/bug\.php$|
- and $uri->query_param('id') =~ /^\d+$/) ? 1 : 0;
+ and $uri->query_param('id') =~ /^\d+$/a) ? 1 : 0;
}
sub _check_value {
# RT URLs can look like various things:
# http://example.com/rt/Ticket/Display.html?id=1234
# https://example.com/Public/Bug/Display.html?id=1234
- return ($uri->path =~ m|/Display\.html$| and $uri->query_param('id') =~ /^\d+$/)
+ return ($uri->path =~ m|/Display\.html$| and $uri->query_param('id') =~ /^\d+$/a)
? 1
: 0;
}
sub should_handle {
my ($class, $uri) = @_;
- return ($uri->path =~ m|/issues/\d+$|) ? 1 : 0;
+ return ($uri->path =~ m|/issues/\d+$|a) ? 1 : 0;
}
sub _check_value {
sub should_handle {
my ($class, $uri) = @_;
- return ($uri->path =~ m|/r/\d+/?$|) ? 1 : 0;
+ return ($uri->path =~ m|/r/\d+/?$|a) ? 1 : 0;
}
sub _check_value {
sub should_handle {
my ($class, $uri) = @_;
return ($uri->authority =~ /\.appspot\.com$/i
- and $uri->path =~ m#^/\d+(?:/|/show)?$#) ? 1 : 0;
+ and $uri->path =~ m#^/\d+(?:/|/show)?$#a) ? 1 : 0;
}
sub _check_value {
# http(s)://example.appspot.com/1234
# http(s)://example.appspot.com/1234/
# http(s)://example.appspot.com/1234/show
- if ($uri->path =~ m#^/(\d+)(?:/|/show)$#) {
+ if ($uri->path =~ m#^/(\d+)(?:/|/show)$#a) {
# This is the shortest standard URL form for Rietveld issues,
# and so we reduce all URLs to this.
sub should_handle {
my ($class, $uri) = @_;
- return ($uri->as_string =~ m|/bugs/(index\.php)?\?\d+$|) ? 1 : 0;
+ return ($uri->as_string =~ m|/bugs/(index\.php)?\?\d+$|a) ? 1 : 0;
}
sub _check_value {
# http(s)://forum.winehq.org/viewtopic.php?f=1234&t=1234
return (lc($uri->authority) eq 'forum.winehq.org'
and $uri->path =~ m|^/viewtopic\.php$|
- and $uri->query_param('f') =~ /^\d+$/
- and $uri->query_param('t') =~ /^\d+$/) ? 1 : 0;
+ and $uri->query_param('f') =~ /^\d+$/a
+ and $uri->query_param('t') =~ /^\d+$/a) ? 1 : 0;
}
sub _check_value {
# are submitted in form fields in which the field names are the bug
# IDs and the field values are the number of votes.
- my @buglist = grep {/^\d+$/} keys %$input;
+ my @buglist = grep {/^\d+$/a} keys %$input;
my (%bugs, %votes);
# If no bugs are in the buglist, let's make sure the user gets notified
# to the wrong attachment. Since the new attachment ID is unknown yet
# let's strip it out for now. We will make a comment with the right ID
# later
- $data =~ s/Created an attachment \(id=\d+\)/Created an attachment/g;
+ $data =~ s/Created an attachment \(id=\d+\)/Created an attachment/ag;
# Same goes for bug #'s Since we don't know if the referenced bug
# is also being moved, lets make sure they know it means a different
# bugzilla.
- $data =~ s/([Bb]ugs?\s*\#?\s*(\d+))/$url$2/g;
+ $data =~ s/([Bb]ugs?\s*\#?\s*(\d+))/$url$2/ag;
# Keep the original commenter if possible, else we will fall back
# to the exporter account.
my %is_private;
foreach my $field (grep(/^defined_isprivate/, $cgi->param())) {
- if ($field =~ /(\d+)$/) {
+ if ($field =~ /(\d+)$/a) {
my $comment_id = $1;
$is_private{$comment_id} = $cgi->param("isprivate_$comment_id");
}
# search or from an old link on the web somewhere) then convert them
# to the new "custom search" format so that the form is populated
# properly.
- my $any_boolean_charts = grep {/^field-?\d+/} $buf->param();
+ my $any_boolean_charts = grep {/^field-?\d+/a} $buf->param();
if ($any_boolean_charts) {
my $search = new Bugzilla::Search(params => scalar $buf->Vars);
$search->boolean_charts_to_custom_search($buf);
# If the name is a single letter followed by numbers, it's part
# of Custom Search. We store these as an array of hashes.
- if ($name =~ /^([[:lower:]])(\d+)$/) {
+ if ($name =~ /^([[:lower:]])(\d+)$/a) {
$default{'custom_search'}->[$2]->{$1} = $values[0];
}
# If the name ends in a number (which it does for the fields which
# are part of the email searching), we use the array
# positions to show the defaults for that number field.
- elsif ($name =~ /^(\w+)(\d)$/) {
+ elsif ($name =~ /^(\w+)(?a:(\d))$/) {
$default{$1}->[$2] = $values[0];
}
else {
for my $row (@rows) {
$data{$tbl}{$col}{$row}++;
$names{"row"}{$row}++;
- $row_isnumeric &&= ($row =~ /^-?\d+(\.\d+)?$/o);
+ $row_isnumeric &&= ($row =~ /^-?\d+(\.\d+)?$/ao);
if ($formatparam eq "table") {
if (!$in_row_total{$row}) {
$data{$tbl}{'-total-'}{$row}++;
}
}
$names{"col"}{$col}++;
- $col_isnumeric &&= ($col =~ /^-?\d+(\.\d+)?$/o);
+ $col_isnumeric &&= ($col =~ /^-?\d+(\.\d+)?$/ao);
}
$names{"tbl"}{$tbl}++;
- $tbl_isnumeric &&= ($tbl =~ /^-?\d+(\.\d+)?$/o);
+ $tbl_isnumeric &&= ($tbl =~ /^-?\d+(\.\d+)?$/ao);
if ($formatparam eq "table") {
$data{$tbl}{'-total-'}{'-total-'}++;
}
my @line = split /\|/;
my $date = $line[0];
- my ($yy, $mm, $dd) = $date =~ /^\d{2}(\d{2})(\d{2})(\d{2})$/;
+ my ($yy, $mm, $dd) = $date =~ /^\d{2}(\d{2})(\d{2})(\d{2})$/a;
push @{$data{DATE}}, "$mm/$dd/$yy";
for my $i (1 .. $#fields) {
push @bugs, Bugzilla::Bug->check({id => $id, cache => 1});
if (defined $cgi->param('mark')) {
foreach my $range (split ',', $cgi->param('mark')) {
- if ($range =~ /^(\d+)-(\d+)$/) {
+ if ($range =~ /^(\d+)-(\d+)$/a) {
foreach my $i ($1 .. $2) {
$marks{$i} = 1;
}
}
- elsif ($range =~ /^(\d+)$/) {
+ elsif ($range =~ /^(\d+)$/a) {
$marks{$1} = 1;
}
}
}
if ($line
- =~ /^rectangle \((\d+),(\d+)\) \((\d+),(\d+)\) (http[^ ]*) (\d+)(?:\\n.*)?$/)
+ =~ /^rectangle \((\d+),(\d+)\) \((\d+),(\d+)\) (http[^ ]*) (\d+)(?:\\n.*)?$/a)
{
my ($leftx, $rightx, $topy, $bottomy, $url, $bugid) = ($1, $3, $2, $4, $5, $6);
local our $hide_resolved = $cgi->param('hide_resolved') ? 1 : 0;
local our $maxdepth = $cgi->param('maxdepth') || 0;
-if ($maxdepth !~ /^\d+$/) {
+if ($maxdepth !~ /^\d+$/a) {
$maxdepth = 0;
}
foreach my $pscmd (@pscmds) {
open PH, '-|', "$pscmd 2>/dev/null";
while (my $line = <PH>) {
- if ($line =~ /^(?:\S*\/)?(?:httpd|apache?)2?\s+(\d+)$/) {
+ if ($line =~ /^(?:\S*\/)?(?:httpd|apache?)2?\s+(?a:(\d+))$/) {
$sgid = $1 if $1 > $sgid;
}
}
# Determine the numeric GID of $webservergroup
my $webgroupnum = 0;
my $webservergroup = Bugzilla->localconfig->{webservergroup};
-if ($webservergroup =~ /^(\d+)$/) {
+if ($webservergroup =~ /^(\d+)$/a) {
$webgroupnum = $1;
}
else {
}
else {
my ($host, $port, $file) = ('', 80, '');
- if ($url =~ m#^http://([^:]+):(\d+)(/.*)#i) {
+ if ($url =~ m#^http://([^:]+):(?a:(\d+))(/.*)#i) {
($host, $port, $file) = ($1, $2, $3);
}
elsif ($url =~ m#^http://([^/]+)(/.*)#i) {
$content .= $line;
}
- my ($status) = $header =~ m#^HTTP/\d+\.\d+ (\d+)#;
- $rtn = (($status =~ /^2\d\d/) ? $content : undef);
+ my ($status) = $header =~ m#^HTTP/(?a:\d+\.\d+) (?a:(\d+))#;
+ $rtn = (($status =~ /^2\d\d/a) ? $content : undef);
}
}
return ($rtn);
# Remove any bug ids the user no longer wants to ignore
foreach my $key (grep(/^remove_ignored_bug_/, $cgi->param)) {
- my ($bug_id) = $key =~ /(\d+)$/;
+ my ($bug_id) = $key =~ /(\d+)$/a;
delete $ignored_bugs{$bug_id};
}
if (&check_today($day)) {
# Values that are not entirely numeric are intervals, like "30min"
- if ($time !~ /^\d+$/) {
+ if ($time !~ /^\d+$/a) {
# set it to now
$sth = $dbh->prepare(
# If configured for a particular time, set it to that, otherwise
# midnight
- my $target_time = ($time =~ /^\d+$/) ? $time : 0;
+ my $target_time = ($time =~ /^\d+$/a) ? $time : 0;
my $run_next
= $dbh->sql_date_math(
# If the schedule is to run today, and it runs many times per day,
# it shall be set to run immediately.
$run_today = &check_today($run_day);
- if (($run_today) && ($run_time !~ /^\d+$/)) {
+ if (($run_today) && ($run_time !~ /^\d+$/a)) {
# The default of 60 catches any bad value
my $minute_interval = 60;
- if ($run_time =~ /^(\d+)min$/i) {
+ if ($run_time =~ /^(\d+)min$/ai) {
$minute_interval = $1;
}
$minute_offset = 0;
# Set the target time if it's a specific hour
- my $target_time = ($run_time =~ /^\d+$/) ? $run_time : 0;
+ my $target_time = ($run_time =~ /^\d+$/a) ? $run_time : 0;
my $nextdate = &get_next_date($run_day);
my $run_next
$add_days = 2;
}
}
- elsif ($day !~ /^\d+$/) { # A specific day of the week
+ elsif ($day !~ /^\d+$/a) { # A specific day of the week
# The default is used if there is a bad value in the database, in
# which case we mark it to a less-popular day (Sunday)
my $day_num = 0;
}
# Sanity check to make sure that none of the <> stuff was left in.
- if ($value =~ /<\d/) {
+ if ($value =~ /<\d/a) {
die $self->name . ": value untranslated: $value\n";
}
return $value;
$value =~ s/<$number-reporter>/$reporter/g;
if ($value =~ /<$number-bug_group>/) {
my @bug_groups = map { $_->name } @{$bug->groups_in};
- @bug_groups = grep { $_ =~ /^\d+-group-/ } @bug_groups;
+ @bug_groups = grep { $_ =~ /^\d+-group-/a } @bug_groups;
my $group = $bug_groups[0];
$value =~ s/<$number-bug_group>/$group/g;
}