From 0abf244f409fd91120d35beb65ee4f3a03139a44 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 23 Mar 2017 23:18:45 -0400 Subject: Bug 1349899 - Clean up invalid mozreview urls on attachment page --- extensions/BMO/lib/Data.pm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'extensions/BMO/lib') diff --git a/extensions/BMO/lib/Data.pm b/extensions/BMO/lib/Data.pm index 5b07ce645..fcb96a558 100644 --- a/extensions/BMO/lib/Data.pm +++ b/extensions/BMO/lib/Data.pm @@ -26,6 +26,22 @@ our @EXPORT = qw( $cf_visible_in_products # Creating an attachment whose contents is a URL matching one of these regexes # will result in the user being redirected to that URL when viewing the # attachment. + +my $mozreview_url_re = qr{ + # begins with mozreview hostname + ^ + https?://reviewboard(?:-dev)?\.(?:allizom|mozilla)\.org + + # followed by a review path + /r/\d+ + + # ends with optional suffix + (?: / + | /diff/\#index_header + )? + $ +}ix; + our %autodetect_attach_urls = ( github_pr => { title => 'GitHub Pull Request', @@ -35,7 +51,7 @@ our %autodetect_attach_urls = ( }, reviewboard => { title => 'MozReview', - regex => qr#^https?://reviewboard(?:-dev)?\.(?:allizom|mozilla)\.org/r/\d+/?#i, + regex => $mozreview_url_re, content_type => 'text/x-review-board-request', can_review => 1, }, -- cgit v1.2.3-24-g4f1b