]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1208947 - Comment links in markdown-based emails are incomplete
authorAlbert Ting <altlist@gmail.com>
Fri, 13 May 2016 19:17:07 +0000 (21:17 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Fri, 13 May 2016 19:17:07 +0000 (21:17 +0200)
r=LpSolit

Bugzilla/Markdown.pm
Bugzilla/Template.pm

index a82e9f3e00b72aa4245fa9fb80b1d64d3084ae00..2951cd4578ef876a057a24bc24b00c943b8eb6c0 100644 (file)
@@ -55,33 +55,27 @@ $g_escape_table{'&lt;'} = md5_hex('&lt;');
 sub new {
     my $invocant = shift;
     my $class = ref $invocant || $invocant;
-    return $class->SUPER::new(tab_width => MARKDOWN_TAB_WIDTH,
+    my $obj = $class->SUPER::new(tab_width => MARKDOWN_TAB_WIDTH,
                               # Bugzilla uses HTML not XHTML
                               empty_element_suffix => '>');
+    $obj->{tab_width} = MARKDOWN_TAB_WIDTH;
+    $obj->{empty_element_suffix} = '>';
+    return $obj;
 }
 
 sub markdown {
-    my $self = shift;
-    my $text = shift;
+    my ($self, $text, $bug, $comment) = @_;
     my $user = Bugzilla->user;
 
     if ($user->settings->{use_markdown}->{is_enabled}
         && $user->setting('use_markdown') eq 'on')
     {
-        return $self->SUPER::markdown($text, @_);
+        $text = $self->_removeFencedCodeBlocks($text);
+        $text = Bugzilla::Template::quoteUrls($text, $bug, $comment, $user, 1);
+        return $self->SUPER::markdown($text);
     }
 
-    return Bugzilla::Template::quoteUrls($text);
-}
-
-sub _Markdown {
-    my $self = shift;
-    my $text = shift;
-
-    $text = $self->_removeFencedCodeBlocks($text);
-    $text = Bugzilla::Template::quoteUrls($text, undef, undef, undef, 1);
-
-    return $self->SUPER::_Markdown($text, @_);
+    return Bugzilla::Template::quoteUrls($text, $bug, $comment, $user);
 }
 
 sub _code_blocks {
index ada5c389c9b6a2a9135def219d1559240f09c28a..49294244adfcbcee2acc744987a897f92dc5a31a 100644 (file)
@@ -163,7 +163,8 @@ sub quoteUrls {
 
     # If the comment is already wrapped, we should ignore newlines when
     # looking for matching regexps. Else we should take them into account.
-    my $s = ($comment && $comment->already_wrapped) ? qr/\s/ : qr/\h/;
+    # And confirm comment is an object, it could be a hash from WebService::Bug::render_comment
+    my $s = ($comment && ref($comment) eq 'Bugzilla::Comment' && $comment->already_wrapped) ? qr/\s/ : qr/\h/;
 
     # However, note that adding the title (for buglinks) can affect things
     # In particular, attachment matches go before bug titles, so that titles
@@ -827,7 +828,7 @@ sub create {
                                       && ((ref($comment) eq 'HASH' && $comment->{is_markdown})
                                          || (ref($comment) eq 'Bugzilla::Comment' && $comment->is_markdown)))
                                   {
-                                      return Bugzilla->markdown->markdown($text);
+                                      return Bugzilla->markdown->markdown($text, $bug, $comment);
                                   }
                                   return quoteUrls($text, $bug, $comment, $user);
                               };