From: Dave Miller Date: Sat, 11 Jul 2026 08:34:32 +0000 (-0400) Subject: Bug 1851421: Use /a with \d to ensure ASCII digit matches (#225) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ab6f70fa938cec438a887b1111a58bab9324dbdb;p=thirdparty%2Fbugzilla.git Bug 1851421: Use /a with \d to ensure ASCII digit matches (#225) r=mrenvoize --- diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index 4e81e31669..1ec554bb99 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -385,7 +385,7 @@ sub datasize { 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; } @@ -844,7 +844,7 @@ sub create { 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) { diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index d34a5cc13c..4af2940718 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -1417,7 +1417,7 @@ sub _check_alias { } # Make sure the alias isn't just a number. - if ($alias =~ /^\d+$/) { + if ($alias =~ /^\d+$/a) { ThrowUserError("alias_is_numeric", {alias => $alias}); } @@ -1758,7 +1758,7 @@ sub _check_dependencies { # 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; } diff --git a/Bugzilla/BugUrl/Debian.pm b/Bugzilla/BugUrl/Debian.pm index d1b2633174..b42cec2d0c 100644 --- a/Bugzilla/BugUrl/Debian.pm +++ b/Bugzilla/BugUrl/Debian.pm @@ -26,8 +26,8 @@ sub should_handle { 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; } @@ -38,7 +38,7 @@ sub _check_value { # 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; diff --git a/Bugzilla/BugUrl/GitHub.pm b/Bugzilla/BugUrl/GitHub.pm index 795a8e317f..884fbe07b8 100644 --- a/Bugzilla/BugUrl/GitHub.pm +++ b/Bugzilla/BugUrl/GitHub.pm @@ -25,7 +25,7 @@ sub should_handle { # 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 { diff --git a/Bugzilla/BugUrl/Google.pm b/Bugzilla/BugUrl/Google.pm index e59655d68c..31a7b3c729 100644 --- a/Bugzilla/BugUrl/Google.pm +++ b/Bugzilla/BugUrl/Google.pm @@ -24,7 +24,7 @@ sub should_handle { # 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 { diff --git a/Bugzilla/BugUrl/JIRA.pm b/Bugzilla/BugUrl/JIRA.pm index 251f054279..219f7978a0 100644 --- a/Bugzilla/BugUrl/JIRA.pm +++ b/Bugzilla/BugUrl/JIRA.pm @@ -23,7 +23,7 @@ sub should_handle { # 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 { diff --git a/Bugzilla/BugUrl/Launchpad.pm b/Bugzilla/BugUrl/Launchpad.pm index e277957735..820102d8a8 100644 --- a/Bugzilla/BugUrl/Launchpad.pm +++ b/Bugzilla/BugUrl/Launchpad.pm @@ -24,7 +24,7 @@ sub should_handle { # 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; } @@ -36,7 +36,7 @@ sub _check_value { # 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; diff --git a/Bugzilla/BugUrl/MantisBT.pm b/Bugzilla/BugUrl/MantisBT.pm index 8b7e66669b..3b147cbc44 100644 --- a/Bugzilla/BugUrl/MantisBT.pm +++ b/Bugzilla/BugUrl/MantisBT.pm @@ -22,7 +22,7 @@ sub should_handle { # 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 { diff --git a/Bugzilla/BugUrl/Trac.pm b/Bugzilla/BugUrl/Trac.pm index 51dd414ff9..38470f06b1 100644 --- a/Bugzilla/BugUrl/Trac.pm +++ b/Bugzilla/BugUrl/Trac.pm @@ -23,7 +23,7 @@ sub should_handle { # 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 { diff --git a/Bugzilla/CGI.pm b/Bugzilla/CGI.pm index 3057f0f8ad..3a578d7932 100644 --- a/Bugzilla/CGI.pm +++ b/Bugzilla/CGI.pm @@ -124,7 +124,7 @@ sub canonicalise_query { # 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); @@ -156,7 +156,7 @@ sub clean_search_url { # 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') { @@ -165,7 +165,7 @@ sub clean_search_url { # 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); } @@ -629,7 +629,7 @@ sub url_is_attachment_base { # 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; diff --git a/Bugzilla/Chart.pm b/Bugzilla/Chart.pm index 551f93c7e4..54d67b20b7 100644 --- a/Bugzilla/Chart.pm +++ b/Bugzilla/Chart.pm @@ -61,7 +61,7 @@ sub init { 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); @@ -70,7 +70,7 @@ sub init { } # Store all the labels - if ($param =~ /^label(\d+)$/) { + if ($param =~ /^label(\d+)$/a) { $self->{'labels'}[$1] = $cgi->param($param); } } diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm index ac5341b1e2..99b2295d3f 100644 --- a/Bugzilla/Comment.pm +++ b/Bugzilla/Comment.pm @@ -458,7 +458,7 @@ sub _check_tag { 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; } diff --git a/Bugzilla/Config/Common.pm b/Bugzilla/Config/Common.pm index f44dd25f0a..1f9c958b51 100644 --- a/Bugzilla/Config/Common.pm +++ b/Bugzilla/Config/Common.pm @@ -97,7 +97,7 @@ sub check_sslbase { # 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; } @@ -353,7 +353,7 @@ sub check_maxattachmentsize { 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 " diff --git a/Bugzilla/DB/Oracle.pm b/Bugzilla/DB/Oracle.pm index ac2f14a63a..30015a0d7a 100644 --- a/Bugzilla/DB/Oracle.pm +++ b/Bugzilla/DB/Oracle.pm @@ -319,7 +319,7 @@ sub adjust_statement { # 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) { @@ -349,7 +349,7 @@ sub adjust_statement { $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; diff --git a/Bugzilla/DB/Pg.pm b/Bugzilla/DB/Pg.pm index 319b7b6c4e..9469453013 100644 --- a/Bugzilla/DB/Pg.pm +++ b/Bugzilla/DB/Pg.pm @@ -250,7 +250,7 @@ sub bz_check_server_version { 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. diff --git a/Bugzilla/Extension.pm b/Bugzilla/Extension.pm index b955fa6381..11c5eb2748 100644 --- a/Bugzilla/Extension.pm +++ b/Bugzilla/Extension.pm @@ -52,7 +52,7 @@ sub load { } else { my $name = require $config_file; - if ($name =~ /^\d+$/) { + if ($name =~ /^\d+$/a) { ThrowCodeError('extension_must_return_name', {extension => $config_file, returned => $name}); } @@ -68,7 +68,7 @@ sub load { } else { my $name = require $extension_file; - if ($name =~ /^\d+$/) { + if ($name =~ /^\d+$/a) { ThrowCodeError('extension_must_return_name', {extension => $extension_file, returned => $name}); } diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm index 8bbc477477..ccc162aa74 100644 --- a/Bugzilla/Flag.pm +++ b/Bugzilla/Flag.pm @@ -847,7 +847,7 @@ sub extract_flags_from_cgi { my $match_status = Bugzilla::User::match_field( - {'^requestee(_type)?-(\d+)$' => {'type' => 'multi'},}, + {'(?a:^requestee(_type)?-(\d+)$)' => {'type' => 'multi'},}, undef, $skip); $vars->{'match_field'} = 'requestee'; @@ -859,11 +859,11 @@ sub extract_flags_from_cgi { } # 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)); @@ -1004,7 +1004,7 @@ sub multi_extract_flags_from_cgi { my $match_status = Bugzilla::User::match_field( - {'^requestee(_type)?-(\d+)$' => {'type' => 'multi'},}, + {'(?a:^requestee(_type)?-(\d+)$)' => {'type' => 'multi'},}, undef, $skip); $vars->{'match_field'} = 'requestee'; @@ -1016,7 +1016,7 @@ sub multi_extract_flags_from_cgi { } # 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); diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 1570a1b4da..d6f1ba654c 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -893,7 +893,7 @@ sub _populate_longdescs { 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); @@ -1146,7 +1146,7 @@ sub _populate_milestones_table { # check if the value already exists my $sortkey = substr($value, 1); - if ($sortkey !~ /^\d+$/) { + if ($sortkey !~ /^\d+$/a) { $sortkey = 0; } else { @@ -1247,7 +1247,7 @@ sub _populate_duplicates_table { 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); @@ -2300,7 +2300,7 @@ sub _copy_old_charts_into_database { 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 @@ -3580,7 +3580,7 @@ sub _fix_illegal_flag_modification_dates { # 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 { @@ -3679,7 +3679,7 @@ sub _set_attachment_comment_type { 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) { diff --git a/Bugzilla/Install/Filesystem.pm b/Bugzilla/Install/Filesystem.pm index 13fee1c115..7cc4ce3805 100644 --- a/Bugzilla/Install/Filesystem.pm +++ b/Bugzilla/Install/Filesystem.pm @@ -729,7 +729,7 @@ sub _update_old_charts { @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) { diff --git a/Bugzilla/Install/Requirements.pm b/Bugzilla/Install/Requirements.pm index 7ed341d8d0..906b42c430 100644 --- a/Bugzilla/Install/Requirements.pm +++ b/Bugzilla/Install/Requirements.pm @@ -747,7 +747,7 @@ sub have_vers { # 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; } } diff --git a/Bugzilla/Install/Util.pm b/Bugzilla/Install/Util.pm index 3b021b9833..ea252c6eca 100644 --- a/Bugzilla/Install/Util.pm +++ b/Bugzilla/Install/Util.pm @@ -183,7 +183,7 @@ sub extension_requirement_packages { 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}); } @@ -538,7 +538,7 @@ sub _sort_accept_language { 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; diff --git a/Bugzilla/Mailer.pm b/Bugzilla/Mailer.pm index 90c08996f7..a2efe59609 100644 --- a/Bugzilla/Mailer.pm +++ b/Bugzilla/Mailer.pm @@ -43,7 +43,7 @@ sub _mail_error_message { # 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; @@ -274,7 +274,7 @@ sub build_thread_marker { $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 '@' } @@ -313,7 +313,7 @@ sub build_message_id { $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 '@' } diff --git a/Bugzilla/Migrate/Gnats.pm b/Bugzilla/Migrate/Gnats.pm index db47b94ce6..aae22a44c9 100644 --- a/Bugzilla/Migrate/Gnats.pm +++ b/Bugzilla/Migrate/Gnats.pm @@ -321,7 +321,7 @@ sub _parse_project { $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; @@ -699,7 +699,7 @@ sub translate_value { # 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/; } } diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm index ee49de84a4..15651f1456 100644 --- a/Bugzilla/Object.pm +++ b/Bugzilla/Object.pm @@ -803,7 +803,7 @@ sub _validate_time { # 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"}); } diff --git a/Bugzilla/RNG.pm b/Bugzilla/RNG.pm index d95ab5d552..6183b4be00 100644 --- a/Bugzilla/RNG.pm +++ b/Bugzilla/RNG.pm @@ -130,7 +130,7 @@ sub _check_seed { # 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"; } } diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index fcd6273abb..53ece5113b 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -130,7 +130,7 @@ use constant NUMBER_REGEX => qr/ \d+ )? $ -/x; + /ax; # If you specify a search type in the boolean charts, this describes # which operator maps to which internal function here. @@ -1542,7 +1542,7 @@ sub _special_parse_chfield { # 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'); @@ -1579,11 +1579,11 @@ sub _special_parse_email { 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; @@ -1685,20 +1685,20 @@ sub _boolean_charts { 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'); @@ -1776,8 +1776,8 @@ sub _field_ids { 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; } @@ -2126,7 +2126,7 @@ sub _timestamp_translate { 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); @@ -2171,7 +2171,7 @@ sub SqlifyDate { 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; } diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm index 13f35c3f0e..1087cdd06a 100644 --- a/Bugzilla/Search/Quicksearch.pm +++ b/Bugzilla/Search/Quicksearch.pm @@ -553,7 +553,7 @@ sub _special_field_syntax { 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'); diff --git a/Bugzilla/Search/Saved.pm b/Bugzilla/Search/Saved.pm index 20cd93804d..e734809009 100644 --- a/Bugzilla/Search/Saved.pm +++ b/Bugzilla/Search/Saved.pm @@ -186,7 +186,7 @@ sub rename_field_value { $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 diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 9348513dc2..ed0ecf1dda 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -904,7 +904,7 @@ sub create { # 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; @@ -1086,7 +1086,7 @@ sub create { } my $version = BUGZILLA_VERSION; - $version =~ /^(\d+)\.(\d+)/; + $version =~ /^(\d+)\.(\d+)/a; if ($2 % 2 == 1) { # second number is odd; development version diff --git a/Bugzilla/Update.pm b/Bugzilla/Update.pm index 239a2fd929..503fa0bf2b 100644 --- a/Bugzilla/Update.pm +++ b/Bugzilla/Update.pm @@ -60,7 +60,7 @@ sub get_notifications { # 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') { @@ -144,7 +144,7 @@ sub get_notifications { # 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. diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 63faac0320..ed828c5bbc 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -437,7 +437,7 @@ sub _set_groups_to_object { # 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)) { @@ -1930,7 +1930,7 @@ sub match_field { # 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; @@ -2597,14 +2597,14 @@ sub validate_password_check { 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' diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index 7e65e35c95..ac098f2c2c 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -361,11 +361,11 @@ sub is_ipv4 { 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. @@ -590,7 +590,7 @@ sub format_time { # 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) { @@ -620,7 +620,7 @@ sub datetime_from { 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 { @@ -782,8 +782,8 @@ sub validate_date { 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; @@ -797,7 +797,7 @@ sub validate_time { 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); } } diff --git a/Bugzilla/Version.pm b/Bugzilla/Version.pm index a96030265b..27410371b7 100644 --- a/Bugzilla/Version.pm +++ b/Bugzilla/Version.pm @@ -211,11 +211,11 @@ sub vers_cmp { 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) { @@ -239,7 +239,7 @@ sub vers_cmp { 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; } diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index b4834d9640..c730c95b23 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -399,7 +399,7 @@ sub get { # 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) { @@ -527,7 +527,7 @@ sub search { 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. diff --git a/Bugzilla/WebService/Server/REST.pm b/Bugzilla/WebService/Server/REST.pm index 2ccc3bbc13..09a25a460e 100644 --- a/Bugzilla/WebService/Server/REST.pm +++ b/Bugzilla/WebService/Server/REST.pm @@ -512,7 +512,7 @@ sub _get_content_prefs { 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++}; diff --git a/Bugzilla/WebService/Server/REST/Resources/Bug.pm b/Bugzilla/WebService/Server/REST/Resources/Bug.pm index 01a75f5ac8..b996e46f71 100644 --- a/Bugzilla/WebService/Server/REST/Resources/Bug.pm +++ b/Bugzilla/WebService/Server/REST/Resources/Bug.pm @@ -134,7 +134,7 @@ sub _rest_resources { params => sub { my $value = $_[0]; my $param = 'names'; - $param = 'ids' if $value =~ /^\d+$/; + $param = 'ids' if $value =~ /^\d+$/a; return {$param => [$_[0]]}; } } diff --git a/Bugzilla/WebService/Server/REST/Resources/BugUserLastVisit.pm b/Bugzilla/WebService/Server/REST/Resources/BugUserLastVisit.pm index 4211edb196..1f74122a41 100644 --- a/Bugzilla/WebService/Server/REST/Resources/BugUserLastVisit.pm +++ b/Bugzilla/WebService/Server/REST/Resources/BugUserLastVisit.pm @@ -18,7 +18,7 @@ BEGIN { sub _rest_resources { return [ # bug-id - qr{^/bug_user_last_visit/(\d+)$}, + qr{^/bug_user_last_visit/(\d+)$}a, { GET => { method => 'get', diff --git a/Bugzilla/WebService/Server/REST/Resources/Classification.pm b/Bugzilla/WebService/Server/REST/Resources/Classification.pm index f70e3cd5e2..4fca8237d8 100644 --- a/Bugzilla/WebService/Server/REST/Resources/Classification.pm +++ b/Bugzilla/WebService/Server/REST/Resources/Classification.pm @@ -25,7 +25,7 @@ sub _rest_resources { GET => { method => 'get', params => sub { - my $param = $_[0] =~ /^\d+$/ ? 'ids' : 'names'; + my $param = $_[0] =~ /^\d+$/a ? 'ids' : 'names'; return {$param => [$_[0]]}; } } diff --git a/Bugzilla/WebService/Server/REST/Resources/FlagType.pm b/Bugzilla/WebService/Server/REST/Resources/FlagType.pm index 2bc4ce6e2f..30da5bf925 100644 --- a/Bugzilla/WebService/Server/REST/Resources/FlagType.pm +++ b/Bugzilla/WebService/Server/REST/Resources/FlagType.pm @@ -44,7 +44,7 @@ sub _rest_resources { PUT => { method => 'update', params => sub { - my $param = $_[0] =~ /^\d+$/ ? 'ids' : 'names'; + my $param = $_[0] =~ /^\d+$/a ? 'ids' : 'names'; return {$param => [$_[0]]}; } } diff --git a/Bugzilla/WebService/Server/REST/Resources/Group.pm b/Bugzilla/WebService/Server/REST/Resources/Group.pm index d2e2604df9..4a82b0b12b 100644 --- a/Bugzilla/WebService/Server/REST/Resources/Group.pm +++ b/Bugzilla/WebService/Server/REST/Resources/Group.pm @@ -30,7 +30,7 @@ sub _rest_resources { PUT => { method => 'update', params => sub { - my $param = $_[0] =~ /^\d+$/ ? 'ids' : 'names'; + my $param = $_[0] =~ /^\d+$/a ? 'ids' : 'names'; return {$param => [$_[0]]}; } } diff --git a/Bugzilla/WebService/Server/REST/Resources/Product.pm b/Bugzilla/WebService/Server/REST/Resources/Product.pm index 2df867e54d..471060db6a 100644 --- a/Bugzilla/WebService/Server/REST/Resources/Product.pm +++ b/Bugzilla/WebService/Server/REST/Resources/Product.pm @@ -38,14 +38,14 @@ sub _rest_resources { 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]]}; } } diff --git a/Bugzilla/WebService/Server/REST/Resources/User.pm b/Bugzilla/WebService/Server/REST/Resources/User.pm index 6b817d88e7..704db4ea69 100644 --- a/Bugzilla/WebService/Server/REST/Resources/User.pm +++ b/Bugzilla/WebService/Server/REST/Resources/User.pm @@ -36,14 +36,14 @@ sub _rest_resources { 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]]}; } } diff --git a/buglist.cgi b/buglist.cgi index 9ff4f69448..a57df83361 100755 --- a/buglist.cgi +++ b/buglist.cgi @@ -136,7 +136,7 @@ if (my $last_list = $cgi->param('regetlastlist')) { # 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; @@ -790,7 +790,7 @@ foreach my $row (@$data) { # 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'}); diff --git a/chart.cgi b/chart.cgi index fb1fc9c78a..409ee1ab39 100755 --- a/chart.cgi +++ b/chart.cgi @@ -75,7 +75,7 @@ $vars->{'doc_section'} = 'using/reports-and-charts.html#charts'; # encode it in the name, as "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; } @@ -236,14 +236,14 @@ exit; # 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; } diff --git a/contrib/bzdbcopy.pl b/contrib/bzdbcopy.pl index d77acb93af..560e790ee6 100755 --- a/contrib/bzdbcopy.pl +++ b/contrib/bzdbcopy.pl @@ -154,7 +154,7 @@ foreach my $table (@table_list) { # 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 diff --git a/contrib/console.pl b/contrib/console.pl index 7c17480644..a299f2386e 100755 --- a/contrib/console.pl +++ b/contrib/console.pl @@ -82,7 +82,7 @@ sub get_object { 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)) { diff --git a/contrib/merge-users.pl b/contrib/merge-users.pl index df68a942c6..9add6abcd9 100755 --- a/contrib/merge-users.pl +++ b/contrib/merge-users.pl @@ -52,7 +52,7 @@ pod2usage(0) if $help; # 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. @@ -75,7 +75,7 @@ else { 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. diff --git a/contrib/sendbugmail.pl b/contrib/sendbugmail.pl index bd34d3daf5..606460cf31 100755 --- a/contrib/sendbugmail.pl +++ b/contrib/sendbugmail.pl @@ -33,7 +33,7 @@ my $bugnum = $ARGV[0]; my $changer = $ARGV[1]; # Validate the bug number. -if (!($bugnum =~ /^(\d+)$/)) { +if (!($bugnum =~ /^(\d+)$/a)) { say STDERR "Bug number \"$bugnum\" not numeric."; usage(); } diff --git a/editproducts.cgi b/editproducts.cgi index 1b1b9b6e5f..d9f7d1d45b 100755 --- a/editproducts.cgi +++ b/editproducts.cgi @@ -350,7 +350,7 @@ if ($action eq 'updategroupcontrols') { 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; diff --git a/email_in.pl b/email_in.pl index eecda81bf7..4d6372fc89 100755 --- a/email_in.pl +++ b/email_in.pl @@ -81,7 +81,7 @@ sub parse_mail { {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); } diff --git a/extensions/Example/Extension.pm b/extensions/Example/Extension.pm index 8201781f76..b950ff2ced 100644 --- a/extensions/Example/Extension.pm +++ b/extensions/Example/Extension.pm @@ -426,7 +426,7 @@ sub email_in_before_parse { 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; } } diff --git a/extensions/MoreBugUrl/lib/BitBucket.pm b/extensions/MoreBugUrl/lib/BitBucket.pm index 6a38092989..bf805a2b18 100644 --- a/extensions/MoreBugUrl/lib/BitBucket.pm +++ b/extensions/MoreBugUrl/lib/BitBucket.pm @@ -23,7 +23,7 @@ sub should_handle { # 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 { @@ -31,7 +31,7 @@ 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; diff --git a/extensions/MoreBugUrl/lib/PHP.pm b/extensions/MoreBugUrl/lib/PHP.pm index e326d8222b..12b42325b6 100644 --- a/extensions/MoreBugUrl/lib/PHP.pm +++ b/extensions/MoreBugUrl/lib/PHP.pm @@ -24,7 +24,7 @@ sub should_handle { # 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 { diff --git a/extensions/MoreBugUrl/lib/RT.pm b/extensions/MoreBugUrl/lib/RT.pm index d23675d6e7..227d8f9172 100644 --- a/extensions/MoreBugUrl/lib/RT.pm +++ b/extensions/MoreBugUrl/lib/RT.pm @@ -23,7 +23,7 @@ sub should_handle { # 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; } diff --git a/extensions/MoreBugUrl/lib/Redmine.pm b/extensions/MoreBugUrl/lib/Redmine.pm index e21ba2e569..bddc5c4f53 100644 --- a/extensions/MoreBugUrl/lib/Redmine.pm +++ b/extensions/MoreBugUrl/lib/Redmine.pm @@ -19,7 +19,7 @@ use base qw(Bugzilla::BugUrl); 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 { diff --git a/extensions/MoreBugUrl/lib/ReviewBoard.pm b/extensions/MoreBugUrl/lib/ReviewBoard.pm index 1da4c4c9ea..6eeccad763 100644 --- a/extensions/MoreBugUrl/lib/ReviewBoard.pm +++ b/extensions/MoreBugUrl/lib/ReviewBoard.pm @@ -19,7 +19,7 @@ use base qw(Bugzilla::BugUrl); 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 { diff --git a/extensions/MoreBugUrl/lib/Rietveld.pm b/extensions/MoreBugUrl/lib/Rietveld.pm index 7febde2374..a4338d4621 100644 --- a/extensions/MoreBugUrl/lib/Rietveld.pm +++ b/extensions/MoreBugUrl/lib/Rietveld.pm @@ -20,7 +20,7 @@ use base qw(Bugzilla::BugUrl); 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 { @@ -32,7 +32,7 @@ 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. diff --git a/extensions/MoreBugUrl/lib/Savane.pm b/extensions/MoreBugUrl/lib/Savane.pm index 69fa10a9d9..b744aaf710 100644 --- a/extensions/MoreBugUrl/lib/Savane.pm +++ b/extensions/MoreBugUrl/lib/Savane.pm @@ -19,7 +19,7 @@ use base qw(Bugzilla::BugUrl); 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 { diff --git a/extensions/MoreBugUrl/lib/WineHQForums.pm b/extensions/MoreBugUrl/lib/WineHQForums.pm index 42e6d99ca0..24c1604cae 100644 --- a/extensions/MoreBugUrl/lib/WineHQForums.pm +++ b/extensions/MoreBugUrl/lib/WineHQForums.pm @@ -24,8 +24,8 @@ sub should_handle { # 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 { diff --git a/extensions/Voting/Extension.pm b/extensions/Voting/Extension.pm index f8674837a6..5ad608cef5 100644 --- a/extensions/Voting/Extension.pm +++ b/extensions/Voting/Extension.pm @@ -508,7 +508,7 @@ sub _update_votes { # 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 diff --git a/importxml.pl b/importxml.pl index 3be5bd2b72..c59f6338c7 100755 --- a/importxml.pl +++ b/importxml.pl @@ -516,12 +516,12 @@ sub process_bug { # 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. diff --git a/process_bug.cgi b/process_bug.cgi index 17ed5a1ee5..143f87c378 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -315,7 +315,7 @@ if (defined $cgi->param('id')) { 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"); } diff --git a/query.cgi b/query.cgi index d7c217788e..031e8cb556 100755 --- a/query.cgi +++ b/query.cgi @@ -115,7 +115,7 @@ sub PrefillForm { # 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); @@ -132,14 +132,14 @@ sub PrefillForm { # 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 { diff --git a/report.cgi b/report.cgi index 6aebe20dc2..5b6ed32d96 100755 --- a/report.cgi +++ b/report.cgi @@ -219,7 +219,7 @@ foreach my $result (@$results) { 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}++; @@ -239,10 +239,10 @@ foreach my $result (@$results) { } } $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-'}++; } diff --git a/reports.cgi b/reports.cgi index 66873e40bb..c84f1a9450 100755 --- a/reports.cgi +++ b/reports.cgi @@ -171,7 +171,7 @@ sub generate_chart { 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) { diff --git a/show_bug.cgi b/show_bug.cgi index 2839abbc07..d67e683aac 100755 --- a/show_bug.cgi +++ b/show_bug.cgi @@ -54,12 +54,12 @@ if ($single) { 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; } } diff --git a/showdependencygraph.cgi b/showdependencygraph.cgi index bf9d560e87..3e495f374c 100755 --- a/showdependencygraph.cgi +++ b/showdependencygraph.cgi @@ -57,7 +57,7 @@ sub CreateImagemap { } 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); diff --git a/showdependencytree.cgi b/showdependencytree.cgi index c4542b42eb..d23fbfef24 100755 --- a/showdependencytree.cgi +++ b/showdependencytree.cgi @@ -39,7 +39,7 @@ my $id = $bug->id; 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; } diff --git a/testserver.pl b/testserver.pl index 3f8784618d..a38533a236 100755 --- a/testserver.pl +++ b/testserver.pl @@ -46,7 +46,7 @@ if (!ON_WINDOWS) { foreach my $pscmd (@pscmds) { open PH, '-|', "$pscmd 2>/dev/null"; while (my $line = ) { - if ($line =~ /^(?:\S*\/)?(?:httpd|apache?)2?\s+(\d+)$/) { + if ($line =~ /^(?:\S*\/)?(?:httpd|apache?)2?\s+(?a:(\d+))$/) { $sgid = $1 if $1 > $sgid; } } @@ -57,7 +57,7 @@ if (!ON_WINDOWS) { # Determine the numeric GID of $webservergroup my $webgroupnum = 0; my $webservergroup = Bugzilla->localconfig->{webservergroup}; -if ($webservergroup =~ /^(\d+)$/) { +if ($webservergroup =~ /^(\d+)$/a) { $webgroupnum = $1; } else { @@ -239,7 +239,7 @@ sub fetch { } 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) { @@ -268,8 +268,8 @@ sub fetch { $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); diff --git a/userprefs.cgi b/userprefs.cgi index 9faada1c20..f41d985eae 100755 --- a/userprefs.cgi +++ b/userprefs.cgi @@ -349,7 +349,7 @@ sub SaveEmail { # 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}; } diff --git a/whine.pl b/whine.pl index b28397c86b..3c7877662c 100755 --- a/whine.pl +++ b/whine.pl @@ -133,7 +133,7 @@ while (my ($schedule_id, $day, $time) = $sched_h->fetchrow_array) { 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( @@ -176,7 +176,7 @@ while (my ($schedule_id, $day, $time) = $sched_h->fetchrow_array) { # 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( @@ -540,11 +540,11 @@ sub reset_timer { # 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; } @@ -563,7 +563,7 @@ sub reset_timer { $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 @@ -647,7 +647,7 @@ sub get_next_date { $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; diff --git a/xt/lib/Bugzilla/Test/Search/FieldTest.pm b/xt/lib/Bugzilla/Test/Search/FieldTest.pm index 2ccaab7353..9ba76a80b6 100644 --- a/xt/lib/Bugzilla/Test/Search/FieldTest.pm +++ b/xt/lib/Bugzilla/Test/Search/FieldTest.pm @@ -466,7 +466,7 @@ sub _translate_value { } # 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; @@ -485,7 +485,7 @@ sub _translate_value_for_bug { $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; }