From d4925824c288627254a6cf42ea1028a1c258022d Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 5 Feb 2013 16:29:09 +0800 Subject: Bug 837944: Linkification for mozilla-inbound changesets broken --- extensions/BMO/Extension.pm | 92 ++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 51 deletions(-) (limited to 'extensions/BMO') diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm index 186a83f73..af29bfaaf 100644 --- a/extensions/BMO/Extension.pm +++ b/extensions/BMO/Extension.pm @@ -509,78 +509,61 @@ sub bug_check_can_change_field { } } -# Purpose: link up various Mozilla-specific strings. -sub _link_uuid { - my $args = shift; - my $match = html_quote($args->{matches}->[0]); - - return qq{bp-$match}; -} - -sub _link_cve { - my $args = shift; - my $match = html_quote($args->{matches}->[0]); - - return qq{$match}; -} - -sub _link_svn { - my $args = shift; - my $match = html_quote($args->{matches}->[0]); - - return qq{r$match}; -} - -sub _link_hg { - my $args = shift; - my $text = html_quote($args->{matches}->[0]); - my $repo = html_quote($args->{matches}->[1]); - my $id = html_quote($args->{matches}->[2]); - - return qq{$text}; -} - -sub _link_bzr { - my $args = shift; - my $preamble = html_quote($args->{matches}->[0]); - my $url = html_quote($args->{matches}->[1]); - my $text = html_quote($args->{matches}->[2]); - my $id = html_quote($args->{matches}->[3]); - - $url =~ s/\s+$//; - $url =~ s/\/$//; - - return qq{$preamble$text}; -} - +# link up various Mozilla-specific strings sub bug_format_comment { my ($self, $args) = @_; my $regexes = $args->{'regexes'}; + # link UUIDs to crash-stats # Only match if not already in an URL using the negative lookbehind (? qr/(? \&_link_uuid + replace => sub { + my $args = shift; + my $match = html_quote($args->{matches}->[0]); + return qq{bp-$match}; + } }); + # link to CVE/CAN security releases push (@$regexes, { match => qr/(? \&_link_cve + replace => sub { + my $args = shift; + my $match = html_quote($args->{matches}->[0]); + return qq{$match}; + } }); - + + # link to svn.m.o push (@$regexes, { match => qr/\br(\d{4,})\b/, - replace => \&_link_svn + replace => sub { + my $args = shift; + my $match = html_quote($args->{matches}->[0]); + return qq{r$match}; + } }); + # link bzr commit messages push (@$regexes, { match => qr/\b(Committing\sto:\sbzr\+ssh:\/\/ - (?:[^\@]+\@)?(bzr\.mozilla\.org[^\n]+)\n.*?\nCommitted\s) + (?:[^\@]+\@)?(bzr\.mozilla\.org[^\n]+)\n.*?\bCommitted\s) (revision\s(\d+))/sx, - replace => \&_link_bzr + replace => sub { + my $args = shift; + my $preamble = html_quote($args->{matches}->[0]); + my $url = html_quote($args->{matches}->[1]); + my $text = html_quote($args->{matches}->[2]); + my $id = html_quote($args->{matches}->[3]); + $url =~ s/\s+$//; + $url =~ s/\/$//; + return qq{$preamble$text}; + } }); + # link to hg.m.o # Note: for grouping in this regexp, always use non-capturing parentheses. my $hgrepos = join('|', qw!(?:releases/)?comm-[\w.]+ (?:releases/)?mozilla-[\w.]+ @@ -591,7 +574,14 @@ sub bug_format_comment { push (@$regexes, { match => qr/\b(($hgrepos)\s+changeset:?\s+(?:\d+:)?([0-9a-fA-F]{12}))\b/, - replace => \&_link_hg + replace => sub { + my $args = shift; + my $text = html_quote($args->{matches}->[0]); + my $repo = html_quote($args->{matches}->[1]); + my $id = html_quote($args->{matches}->[2]); + $repo = 'integration/mozilla-inbound' if $repo eq 'mozilla-inbound'; + return qq{$text}; + } }); } -- cgit v1.2.3-24-g4f1b