From f5fc4a6d6bf930607d8dd5cd7ffeb78a1044918f Mon Sep 17 00:00:00 2001 From: David Lawrence Date: Tue, 4 Nov 2014 21:46:41 +0000 Subject: Revert Bug 330707 - Add optional support for MarkDown --- Bugzilla/Bug.pm | 7 +- Bugzilla/Comment.pm | 18 -- Bugzilla/Constants.pm | 6 - Bugzilla/DB/Schema.pm | 3 +- Bugzilla/Install.pm | 2 - Bugzilla/Install/DB.pm | 4 - Bugzilla/Install/Requirements.pm | 9 - Bugzilla/Markdown.pm | 520 --------------------------------------- Bugzilla/Template.pm | 30 +-- Bugzilla/User.pm | 14 -- Bugzilla/WebService/Bug.pm | 130 ++-------- Bugzilla/WebService/Constants.pm | 1 - 12 files changed, 26 insertions(+), 718 deletions(-) delete mode 100644 Bugzilla/Markdown.pm (limited to 'Bugzilla') diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index aec7c1e82..7b97d1ff8 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -694,8 +694,6 @@ sub create { unless defined $params->{rep_platform}; # Make sure a comment is always defined. $params->{comment} = '' unless defined $params->{comment}; - $params->{is_markdown} = 0 - unless defined $params->{is_markdown} && $params->{is_markdown} eq '1'; $class->check_required_create_fields($params); $params = $class->run_create_validators($params); @@ -709,7 +707,6 @@ sub create { my $blocked = delete $params->{blocked}; my $keywords = delete $params->{keywords}; my $creation_comment = delete $params->{comment}; - my $is_markdown = delete $params->{is_markdown}; my $see_also = delete $params->{see_also}; # We don't want the bug to appear in the system until it's correctly @@ -797,7 +794,6 @@ sub create { # We now have a bug id so we can fill this out $creation_comment->{'bug_id'} = $bug->id; - $creation_comment->{'is_markdown'} = $is_markdown; # Insert the comment. We always insert a comment on bug creation, # but sometimes it's blank. @@ -2430,8 +2426,7 @@ sub set_all { # there are lots of things that want to check if we added a comment. $self->add_comment($params->{'comment'}->{'body'}, { isprivate => $params->{'comment'}->{'is_private'}, - work_time => $params->{'work_time'}, - is_markdown => $params->{'comment'}->{'is_markdown'} }); + work_time => $params->{'work_time'} }); } if (exists $params->{alias} && $params->{alias}{set}) { diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm index 3dabe6702..c235b8d30 100644 --- a/Bugzilla/Comment.pm +++ b/Bugzilla/Comment.pm @@ -43,7 +43,6 @@ use constant DB_COLUMNS => qw( already_wrapped type extra_data - is_markdown ); use constant UPDATE_COLUMNS => qw( @@ -66,7 +65,6 @@ use constant VALIDATORS => { work_time => \&_check_work_time, thetext => \&_check_thetext, isprivate => \&_check_isprivate, - is_markdown => \&Bugzilla::Object::check_boolean, extra_data => \&_check_extra_data, type => \&_check_type, }; @@ -179,7 +177,6 @@ sub body { return $_[0]->{'thetext'}; } sub bug_id { return $_[0]->{'bug_id'}; } sub creation_ts { return $_[0]->{'bug_when'}; } sub is_private { return $_[0]->{'isprivate'}; } -sub is_markdown { return $_[0]->{'is_markdown'}; } sub work_time { # Work time is returned as a string (see bug 607909) return 0 if $_[0]->{'work_time'} + 0 == 0; @@ -277,7 +274,6 @@ sub body_full { sub set_is_private { $_[0]->set('isprivate', $_[1]); } sub set_type { $_[0]->set('type', $_[1]); } sub set_extra_data { $_[0]->set('extra_data', $_[1]); } -sub set_is_markdown { $_[0]->set('is_markdown', $_[1]); } sub add_tag { my ($self, $tag) = @_; @@ -526,10 +522,6 @@ C Time spent as related to this comment. C Comment is marked as private. -=item C - -C Whether this comment needs L rendering to be applied. - =item C If this comment is stored in the database word-wrapped, this will be C<1>. @@ -625,16 +617,6 @@ A string, the full text of the comment as it would be displayed to an end-user. =cut -=head2 Modifiers - -=over - -=item C - -Sets whether this comment needs L rendering to be applied. - -=back - =head1 B =over diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index 4c1f11003..4f5ec581d 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -193,8 +193,6 @@ use Memoize; AUDIT_REMOVE MOST_FREQUENT_THRESHOLD - - MARKDOWN_TAB_WIDTH ); @Bugzilla::Constants::EXPORT_OK = qw(contenttypes); @@ -637,10 +635,6 @@ use constant AUDIT_REMOVE => '__remove__'; # on the "Most frequently reported bugs" page. use constant MOST_FREQUENT_THRESHOLD => 2; -# The number of spaces used to represent each tab character -# by Markdown engine -use constant MARKDOWN_TAB_WIDTH => 2; - sub bz_locations { # Force memoize() to re-compute data per project, to avoid # sharing the same data across different installations. diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index ebe2cb426..d1c1dc7e9 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -410,8 +410,7 @@ use constant ABSTRACT_SCHEMA => { DEFAULT => 'FALSE'}, type => {TYPE => 'INT2', NOTNULL => 1, DEFAULT => '0'}, - extra_data => {TYPE => 'varchar(255)'}, - is_markdown => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'} + extra_data => {TYPE => 'varchar(255)'} ], INDEXES => [ longdescs_bug_id_idx => [qw(bug_id work_time)], diff --git a/Bugzilla/Install.pm b/Bugzilla/Install.pm index 5a2266e36..07bc9d6c3 100644 --- a/Bugzilla/Install.pm +++ b/Bugzilla/Install.pm @@ -90,8 +90,6 @@ sub SETTINGS { bugmail_new_prefix => { options => ['on', 'off'], default => 'on' }, # 2013-07-26 joshi_sunil@in.com -- Bug 669535 possible_duplicates => { options => ['on', 'off'], default => 'on' }, - # 2014-05-24 koosha.khajeh@gmail.com -- Bug 1014164 - use_markdown => { options => ['on', 'off'], default => 'on' }, } }; diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index ab02fe41d..8ffde11fd 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -726,10 +726,6 @@ sub update_table_definitions { # 2014-08-11 sgreen@redhat.com - Bug 1012506 _update_alias(); - # 2014-08-14 koosha.khajeh@gmail.com - Bug 330707 - $dbh->bz_add_column('longdescs', 'is_markdown', - {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'FALSE'}); - ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ diff --git a/Bugzilla/Install/Requirements.pm b/Bugzilla/Install/Requirements.pm index db3d7b028..48e992db7 100644 --- a/Bugzilla/Install/Requirements.pm +++ b/Bugzilla/Install/Requirements.pm @@ -396,14 +396,6 @@ sub OPTIONAL_MODULES { version => '0', feature => ['memcached'], }, - - # Markdown - { - package => 'Text-Markdown', - module => 'Text::Markdown', - version => '1.0.26', - feature => ['markdown'], - } ); my $extra_modules = _get_extension_requirements('OPTIONAL_MODULES'); @@ -427,7 +419,6 @@ use constant FEATURE_FILES => ( 'Bugzilla/JobQueue/*', 'jobqueue.pl'], patch_viewer => ['Bugzilla/Attachment/PatchReader.pm'], updates => ['Bugzilla/Update.pm'], - markdown => ['Bugzilla/Markdown.pm'], memcached => ['Bugzilla/Memcache.pm'], ); diff --git a/Bugzilla/Markdown.pm b/Bugzilla/Markdown.pm deleted file mode 100644 index 353c2ff6a..000000000 --- a/Bugzilla/Markdown.pm +++ /dev/null @@ -1,520 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# This Source Code Form is "Incompatible With Secondary Licenses", as -# defined by the Mozilla Public License, v. 2.0. - -package Bugzilla::Markdown; - -use 5.10.1; -use strict; -use warnings; - -use Bugzilla::Constants; -use Bugzilla::Template; - -use Digest::MD5 qw(md5_hex); - -use parent qw(Text::Markdown); - -@Bugzilla::Markdown::EXPORT = qw(new); - -# Regex to match balanced [brackets]. See Friedl's -# "Mastering Regular Expressions", 2nd Ed., pp. 328-331. -our ($g_nested_brackets, $g_nested_parens); -$g_nested_brackets = qr{ - (?> # Atomic matching - [^\[\]]+ # Anything other than brackets - | - \[ - (??{ $g_nested_brackets }) # Recursive set of nested brackets - \] - )* -}x; -# Doesn't allow for whitespace, because we're using it to match URLs: -$g_nested_parens = qr{ - (?> # Atomic matching - [^()\s]+ # Anything other than parens or whitespace - | - \( - (??{ $g_nested_parens }) # Recursive set of nested brackets - \) - )* -}x; - -our %g_escape_table; -foreach my $char (split //, '\\`*_{}[]()>#+-.!~') { - $g_escape_table{$char} = md5_hex($char); -} -$g_escape_table{'<'} = md5_hex('<'); - -sub new { - my $invocant = shift; - my $class = ref $invocant || $invocant; - return $class->SUPER::new(tab_width => MARKDOWN_TAB_WIDTH, - # Bugzilla uses HTML not XHTML - empty_element_suffix => '>'); -} - -sub markdown { - my $self = shift; - my $text = shift; - my $user = Bugzilla->user; - - if ($user->settings->{use_markdown}->{is_enabled} - && $user->setting('use_markdown') eq 'on') - { - return $self->SUPER::markdown($text, @_); - } - - return Bugzilla::Template::quoteUrls($text); -} - -sub _Markdown { - my $self = shift; - my $text = shift; - - $text = Bugzilla::Template::quoteUrls($text, undef, undef, undef, undef, 1); - - return $self->SUPER::_Markdown($text, @_); -} - -sub _RunSpanGamut { - # These are all the transformations that occur *within* block-level - # tags like paragraphs, headers, and list items. - - my ($self, $text) = @_; - - $text = $self->_DoCodeSpans($text); - $text = $self->_EscapeSpecialCharsWithinTagAttributes($text); - $text = $self->_EscapeSpecialChars($text); - - $text = $self->_DoAnchors($text); - - # Strikethroughs is Bugzilla's extension - $text = $self->_DoStrikethroughs($text); - - $text = $self->_DoAutoLinks($text); - $text = $self->_EncodeAmpsAndAngles($text); - $text = $self->_DoItalicsAndBold($text); - - $text =~ s/\n/{empty_element_suffix}\n/g; - - return $text; -} - -# Override to check for HTML-escaped <>" chars. -sub _StripLinkDefinitions { -# -# Strips link definitions from text, stores the URLs and titles in -# hash references. -# - my ($self, $text) = @_; - my $less_than_tab = $self->{tab_width} - 1; - - # Link defs are in the form: ^[id]: url "optional title" - while ($text =~ s{ - ^[ ]{0,$less_than_tab}\[(.+)\]: # id = \$1 - [ \t]* - \n? # maybe *one* newline - [ \t]* - (?:<)?\2(?:>)? # url = \$2 - [ \t]* - \n? # maybe one newline - [ \t]* - (?: - (?<=\s) # lookbehind for whitespace - (?:"|\() - (.+?) # title = \$3 - (?:"|\)) - [ \t]* - )? # title is optional - (?:\n+|\Z) - }{}omx) { - $self->{_urls}{lc $1} = $self->_EncodeAmpsAndAngles( $2 ); # Link IDs are case-insensitive - if ($3) { - $self->{_titles}{lc $1} = $3; - $self->{_titles}{lc $1} =~ s/"/"/g; - } - - } - - return $text; -} - -# We need to look for HTML-escaped '<' and '>' (i.e. < and >). -# We also remove Email linkification from the original implementation -# as it is already done in Bugzilla's quoteUrls(). -sub _DoAutoLinks { - my ($self, $text) = @_; - - $text =~ s{(?:<|<)((?:https?|ftp):[^'">\s]+?)(?:>|>)}{$1}gi; - return $text; -} - -# The main reasons for overriding this method are -# resolving URL conflicts with Bugzilla's quoteUrls() -# and also changing '"' to '"' in regular expressions wherever needed. -sub _DoAnchors { -# -# Turn Markdown link shortcuts into tags. -# - my ($self, $text) = @_; - - # We revert linkifications of non-email links and only - # those links whose URL and title are the same because - # this way we can be sure that link is generated by quoteUrls() - $text =~ s@\1@$1@xmg; - - # - # First, handle reference-style links: [link text] [id] - # - $text =~ s{ - ( # wrap whole match in $1 - \[ - ($g_nested_brackets) # link text = $2 - \] - - [ ]? # one optional space - (?:\n[ ]*)? # one optional newline followed by spaces - - \[ - (.*?) # id = $3 - \] - ) - }{ - my $whole_match = $1; - my $link_text = $2; - my $link_id = lc $3; - - if ($link_id eq "") { - $link_id = lc $link_text; # for shortcut links like [this][]. - } - - $link_id =~ s{[ ]*\n}{ }g; # turn embedded newlines into spaces - - $self->_GenerateAnchor($whole_match, $link_text, $link_id); - }xsge; - - # - # Next, inline-style links: [link text](url "optional title") - # - $text =~ s{ - ( # wrap whole match in $1 - \[ - ($g_nested_brackets) # link text = $2 - \] - \( # literal paren - [ \t]* - ($g_nested_parens) # href = $3 - [ \t]* - ( # $4 - ("|') # quote char = $5 - (.*?) # Title = $6 - \5 # matching quote - [ \t]* # ignore any spaces/tabs between closing quote and ) - )? # title is optional - \) - ) - }{ - my $result; - my $whole_match = $1; - my $link_text = $2; - my $url = $3; - my $title = $6; - - # Remove Bugzilla quoteUrls() linkification - if ($url =~ /^a href="/ && $url =~ m|]+>//; - $url =~ s@_GenerateAnchor($whole_match, $link_text, undef, $url, $title); - }xsge; - - # - # Last, handle reference-style shortcuts: [link text] - # These must come last in case you've also got [link test][1] - # or [link test](/foo) - # - $text =~ s{ - ( # wrap whole match in $1 - \[ - ([^\[\]]+) # link text = $2; can't contain '[' or ']' - \] - ) - }{ - my $result; - my $whole_match = $1; - my $link_text = $2; - (my $link_id = lc $2) =~ s{[ ]*\n}{ }g; # lower-case and turn embedded newlines into spaces - - $self->_GenerateAnchor($whole_match, $link_text, $link_id); - }xsge; - - return $text; -} - -# The purpose of overriding this function is to add support -# for a Github Flavored Markdown (GFM) feature called 'Multiple -# underscores in words'. The standard markdown specification -# specifies the underscore for making the text emphasized/bold. -# However, some variable names in programming languages contain underscores -# and we do not want a part of those variables to look emphasized/bold. -# Instead, we render them as the way they originally are. -sub _DoItalicsAndBold { - my ($self, $text) = @_; - - # Handle at beginning of lines: - $text =~ s{ (^__ (?=\S) (.+?[*_]*) (?<=\S) __ (?!\S)) } - { - my $result = _has_multiple_underscores($2) ? $1 : "$2"; - $result; - }gsxe; - - $text =~ s{ ^\*\* (?=\S) (.+?[*_]*) (?<=\S) \*\* }{$1}gsx; - - $text =~ s{ (^_ (?=\S) (.+?) (?<=\S) _ (?!\S)) } - { - my $result = _has_multiple_underscores($2) ? $1 : "$2"; - $result; - }gsxe; - - $text =~ s{ ^\* (?=\S) (.+?) (?<=\S) \* }{$1}gsx; - - # must go first: - $text =~ s{ ( (?<=\W) __ (?=\S) (.+?[*_]*) (?<=\S) __ (?!\S) ) } - { - my $result = _has_multiple_underscores($2) ? $1 : "$2"; - $result; - }gsxe; - - - $text =~ s{ (?<=\W) \*\* (?=\S) (.+?[*_]*) (?<=\S) \*\* }{$1}gsx; - - $text =~ s{ ( (?<=\W) _ (?=\S) (.+?) (?<=\S) _ (?!\S) ) } - { - my $result = _has_multiple_underscores($2) ? $1 : "$2"; - $result; - }gsxe; - - $text =~ s{ (?<=\W) \* (?=\S) (.+?) (?<=\S) \* }{$1}gsx; - - # And now, a second pass to catch nested strong and emphasis special cases - $text =~ s{ ( (?<=\W) __ (?=\S) (.+?[*_]*) (?<=\S) __ (\S*) ) } - { - my $result = _has_multiple_underscores($3) ? $1 : "$2$3"; - $result; - }gsxe; - - $text =~ s{ (?<=\W) \*\* (?=\S) (.+?[*_]*) (?<=\S) \*\* }{$1}gsx; - $text =~ s{ ( (?<=\W) _ (?=\S) (.+?) (?<=\S) _ (\S*) ) } - { - my $result = _has_multiple_underscores($3) ? $1 : "$2$3"; - $result; - }gsxe; - - $text =~ s{ (?<=\W) \* (?=\S) (.+?) (?<=\S) \* }{$1}gsx; - - return $text; -} - -sub _DoStrikethroughs { - my ($self, $text) = @_; - - $text =~ s{ ^ ~~ (?=\S) ([^~]+?) (?<=\S) ~~ (?!~) }{$1}gsx; - $text =~ s{ (?<=_|[^~\w]) ~~ (?=\S) ([^~]+?) (?<=\S) ~~ (?!~) }{$1}gsx; - - return $text; -} - -# The original _DoCodeSpans() uses the 's' modifier in its regex -# which prevents _DoCodeBlocks() to match GFM fenced code blocks. -# We copy the code from the original implementation and remove the -# 's' modifier from it. -sub _DoCodeSpans { - my ($self, $text) = @_; - - $text =~ s@ - (?_EncodeCode($c); - "$c"; - @egx; - - return $text; -} - -# Override to add GFM Fenced Code Blocks -sub _DoCodeBlocks { - my ($self, $text) = @_; - - $text =~ s{ - ^ `{3,} [\s\t]* \n - ( # $1 = the entire code block - (?: .* \n+)+? - ) - `{3,} [\s\t]* $ - }{ - my $codeblock = $1; - my $result; - - $codeblock = $self->_EncodeCode($codeblock); - $codeblock = $self->_Detab($codeblock); - $codeblock =~ s/\n\z//; # remove the trailing newline - - $result = "\n\n
" . $codeblock . "
\n\n"; - $result; - }egmx; - - # And now do the standard code blocks - $text = $self->SUPER::_DoCodeBlocks($text); - - return $text; -} - -sub _DoBlockQuotes { - my ($self, $text) = @_; - - $text =~ s{ - ( # Wrap whole match in $1 - (?: - ^[ \t]*>[ \t]? # '>' at the start of a line - .+\n # rest of the first line - (?:.+\n)* # subsequent consecutive lines - \n* # blanks - )+ - ) - }{ - my $bq = $1; - $bq =~ s/^[ \t]*>[ \t]?//gm; # trim one level of quoting - $bq =~ s/^[ \t]+$//mg; # trim whitespace-only lines - $bq = $self->_RunBlockGamut($bq, {wrap_in_p_tags => 1}); # recurse - $bq =~ s/^/ /mg; - # These leading spaces screw with
 content, so we need to fix that:
-            $bq =~ s{(\s*
.+?
)}{ - my $pre = $1; - $pre =~ s/^ //mg; - $pre; - }egs; - "
\n$bq\n
\n\n"; - }egmx; - - return $text; -} - -sub _EncodeCode { - my ($self, $text) = @_; - - # We need to unescape the escaped HTML characters in code blocks. - # These are the reverse of the escapings done in Bugzilla::Util::html_quote() - $text =~ s/<//g; - $text =~ s/"/"/g; - $text =~ s/@/@/g; - # '&' substitution must be the last one, otherwise a literal like '>' - # will turn to '>' because '&' is already changed to '&' in Bugzilla::Util::html_quote(). - # In other words, html_quote() will change '>' to '&gt;' and then we will - # change '&gt' -> '>' -> '>' if we write this substitution as the first one. - $text =~ s/&/&/g; - $text =~ s{ \1 }{$1}xmgi; - $text = $self->SUPER::_EncodeCode($text); - $text =~ s/~/$g_escape_table{'~'}/go; - # Encode '<' to prevent URLs from getting linkified in code spans - $text =~ s/</$g_escape_table{'<'}/go; - - return $text; -} - -sub _EncodeBackslashEscapes { - my ($self, $text) = @_; - - $text = $self->SUPER::_EncodeBackslashEscapes($text); - $text =~ s/\\~/$g_escape_table{'~'}/go; - - return $text; -} - -sub _UnescapeSpecialChars { - my ($self, $text) = @_; - - $text = $self->SUPER::_UnescapeSpecialChars($text); - $text =~ s/$g_escape_table{'~'}/~/go; - $text =~ s/$g_escape_table{'<'}/</go; - - return $text; -} - -# Check if the passed string is of the form multiple_underscores_in_a_word. -# To check that, we first need to make sure that the string does not contain -# any white-space. Then, if the string is composed of non-space chunks which -# are bound together with underscores, the string has the desired form. -sub _has_multiple_underscores { - my $string = shift; - return 0 unless defined($string) && length($string); - return 0 if $string =~ /[\t\s]+/; - return 1 if scalar (split /_/, $string) > 1; - return 0; -} - -1; - -__END__ - -=head1 NAME - -Bugzilla::Markdown - Generates HTML output from structured plain-text input. - -=head1 SYNOPSIS - - use Bugzilla::Markdown; - - my $markdown = Bugzilla::Markdown->new(); - print $markdown->markdown($text); - -=head1 DESCRIPTION - -Bugzilla::Markdown implements a Markdown engine that produces -an HTML-based output from a given plain-text input. - -The majority of the implementation is done by C -CPAN module. It also applies the linkifications done in L -to the input resulting in an output which is a combination of both Markdown -structures and those defined by Bugzilla itself. - -=head2 Accessors - -=over - -=item C - -C Produces an HTML-based output string based on the structures -and format defined in the given plain-text input. - -=over - -=item B - -=over - -=item C - -C A plain-text string which includes Markdown structures. - -=back - -=back - -=back diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 7ce1be72b..bb8ff3b74 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -148,11 +148,10 @@ sub get_format { # If you want to modify this routine, read the comments carefully sub quoteUrls { - my ($text, $bug, $comment, $user, $bug_link_func, $for_markdown) = @_; + my ($text, $bug, $comment, $user, $bug_link_func) = @_; return $text unless $text; $user ||= Bugzilla->user; $bug_link_func ||= \&get_bug_link; - $for_markdown ||= 0; # We use /g for speed, but uris can have other things inside them # (http://foo/bug#3 for example). Filtering that out filters valid @@ -223,11 +222,10 @@ sub quoteUrls { $text = html_quote($text); - unless ($for_markdown) { - # Color quoted text - $text =~ s~^(>.+)$~$1~mg; - $text =~ s~\n~\n~g; - } + # Color quoted text + $text =~ s~^(>.+)$~$1~mg; + $text =~ s~\n~\n~g; + # mailto: # Use | so that $1 is defined regardless # @ is the encoded '@' character. @@ -858,24 +856,6 @@ sub create { 1 ], - markdown => [ sub { - my ($context, $bug, $comment, $user) = @_; - return sub { - my $text = shift; - return unless $text; - - if (Bugzilla->feature('markdown') - && ((ref($comment) eq 'HASH' && $comment->{is_markdown}) - || (ref($comment) eq 'Bugzilla::Comment' && $comment->is_markdown))) - { - return Bugzilla->markdown->markdown($text); - } - return quoteUrls($text, $bug, $comment, $user); - }; - }, - 1 - ], - bug_link => [ sub { my ($context, $bug, $options) = @_; return sub { diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index fa2674366..acedc65f2 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -632,14 +632,6 @@ sub is_bug_ignored { return (grep {$_->{'id'} == $bug_id} @{$self->bugs_ignored}) ? 1 : 0; } -sub use_markdown { - my ($self, $comment) = @_; - return Bugzilla->feature('markdown') - && $self->settings->{use_markdown}->{is_enabled} - && $self->settings->{use_markdown}->{value} eq 'on' - && (!defined $comment || $comment->is_markdown); -} - ########################## # Saved Recent Bug Lists # ########################## @@ -2631,12 +2623,6 @@ C The current summary of the bug. Returns true if the user does not want email notifications for the specified bug ID, else returns false. -=item C - -Returns true if the user has set their preferences to use Markdown -for rendering comments. If an optional C object is passed -then it returns true if the comment has markdown enabled. - =back =head2 Saved Recent Bug Lists diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index f50bb6aee..7c28b1d8d 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -331,9 +331,7 @@ sub render_comment { Bugzilla->switch_to_shadow_db(); my $bug = $params->{id} ? Bugzilla::Bug->check($params->{id}) : undef; - my $markdown = $params->{markdown} ? 1 : 0; - my $tmpl = $markdown ? '[% text FILTER markdown(bug, { is_markdown => 1 }) %]' : '[% text FILTER markdown(bug) %]'; - + my $tmpl = '[% text FILTER quoteUrls(bug) %]'; my $html; my $template = Bugzilla->template; $template->process( @@ -352,16 +350,15 @@ sub _translate_comment { : undef; my $comment_hash = { - id => $self->type('int', $comment->id), - bug_id => $self->type('int', $comment->bug_id), - creator => $self->type('email', $comment->author->login), - time => $self->type('dateTime', $comment->creation_ts), + id => $self->type('int', $comment->id), + bug_id => $self->type('int', $comment->bug_id), + creator => $self->type('email', $comment->author->login), + time => $self->type('dateTime', $comment->creation_ts), creation_time => $self->type('dateTime', $comment->creation_ts), - is_private => $self->type('boolean', $comment->is_private), - is_markdown => $self->type('boolean', $comment->is_markdown), - text => $self->type('string', $comment->body_full), + is_private => $self->type('boolean', $comment->is_private), + text => $self->type('string', $comment->body_full), attachment_id => $self->type('int', $attach_id), - count => $self->type('int', $comment->count), + count => $self->type('int', $comment->count), }; # Don't load comment tags unless enabled @@ -825,20 +822,10 @@ sub add_attachment { $attachment->update($timestamp); my $comment = $params->{comment} || ''; - - my $is_markdown = 0; - if (ref $params->{comment} eq 'HASH') { - $is_markdown = $params->{comment}->{is_markdown}; - $comment = $params->{comment}->{body}; - } - - ThrowUserError('markdown_disabled') if $is_markdown && !_is_markdown_enabled(); - - $attachment->bug->add_comment($comment, - { is_markdown => $is_markdown, - isprivate => $attachment->isprivate, - type => CMT_ATTACHMENT_CREATED, - extra_data => $attachment->id }); + $attachment->bug->add_comment($comment, + { isprivate => $attachment->isprivate, + type => CMT_ATTACHMENT_CREATED, + extra_data => $attachment->id }); push(@created, $attachment); } $_->bug->update($timestamp) foreach @created; @@ -884,14 +871,6 @@ sub update_attachment { my $flags = delete $params->{flags}; my $comment = delete $params->{comment}; - my $is_markdown = 0; - - if (ref $comment eq 'HASH') { - $is_markdown = $comment->{is_markdown}; - $comment = $comment->{body}; - } - - ThrowUserError('markdown_disabled') if $is_markdown && !_is_markdown_enabled(); # Update the values foreach my $attachment (@attachments) { @@ -911,10 +890,9 @@ sub update_attachment { if ($comment = trim($comment)) { $attachment->bug->add_comment($comment, - { is_markdown => $is_markdown, - isprivate => $attachment->isprivate, - type => CMT_ATTACHMENT_UPDATED, - extra_data => $attachment->id }); + { isprivate => $attachment->isprivate, + type => CMT_ATTACHMENT_UPDATED, + extra_data => $attachment->id }); } $changes = translate($changes, ATTACHMENT_MAPPED_RETURNS); @@ -971,13 +949,9 @@ sub add_comment { if (defined $params->{private}) { $params->{is_private} = delete $params->{private}; } - - ThrowUserError('markdown_disabled') if $params->{is_markdown} && !_is_markdown_enabled(); - # Append comment - $bug->add_comment($comment, { isprivate => $params->{is_private}, - is_markdown => $params->{is_markdown}, - work_time => $params->{work_time} }); + $bug->add_comment($comment, { isprivate => $params->{is_private}, + work_time => $params->{work_time} }); # Capture the call to bug->update (which creates the new comment) in # a transaction so we're sure to get the correct comment_id. @@ -1425,14 +1399,6 @@ sub _add_update_tokens { } } -sub _is_markdown_enabled { - my $user = Bugzilla->user; - - return Bugzilla->feature('markdown') - && $user->settings->{use_markdown}->{is_enabled} - && $user->setting('use_markdown') eq 'on'; -} - 1; __END__ @@ -2110,10 +2076,6 @@ may be deprecated and removed in a future release. C True if this comment is private (only visible to a certain group called the "insidergroup"), False otherwise. -=item is_markdown - -C True if this comment needs Markdown processing, false otherwise. - =back =item B @@ -3131,9 +3093,6 @@ don't want it to be assigned to the component owner. =item C (boolean) - If set to true, the description is private, otherwise it is assumed to be public. -=item C (boolean) - If set to true, the description -has Markdown structures, otherwise it is a normal text. - =item C (array) - An array of group names to put this bug into. You can see valid group names on the Permissions tab of the Preferences screen, or, if you are an administrator, @@ -3289,8 +3248,6 @@ Bugzilla B<4.4>. =item REST API call added in Bugzilla B<5.0>. -=item C option added in Bugzilla B<5.0>. - =back =back @@ -3350,21 +3307,7 @@ C or C. =item C -C or hash. A comment to add along with this attachment. If C -is a hash, it has the following keys: - -=over - -=item C - -C The body of the comment. - -=item C - -C If set to true, the comment has Markdown structures; otherwise, it -is an ordinary text. - -=back +C A comment to add along with this attachment. =item C @@ -3442,10 +3385,6 @@ the type id value to update or add a flag. The flag type is inactive and cannot be used to create new flags. -=item 140 (Markdown Disabled) - -You tried to set the C flag of the comment to true but the Markdown feature is not enabled. - =item 600 (Attachment Too Large) You tried to attach a file that was larger than Bugzilla will accept. @@ -3481,8 +3420,6 @@ You set the "data" field to an empty string. =item REST API call added in Bugzilla B<5.0>. -=item C added in Bugzilla B<5.0>. - =back =back @@ -3529,21 +3466,7 @@ attachment. =item C -C or hash: An optional comment to add to the attachment's bug. If C is -a hash, it has the following keys: - -=over - -=item C - -C The body of the comment to be added. - -=item C - -C If set to true, the comment has Markdown structures; otherwise it is a normal -text. - -=back +C An optional comment to add to the attachment's bug. =item C @@ -3692,11 +3615,6 @@ the type id value to update or add a flag. The flag type is inactive and cannot be used to create new flags. -=item 140 (Markdown Disabled) - -You tried to set the C flag of the C to true but Markdown feature is -not enabled. - =item 601 (Invalid MIME Type) You specified a C argument that was blank, not a valid @@ -3757,9 +3675,6 @@ you did not set the C parameter. =item C (boolean) - If set to true, the comment is private, otherwise it is assumed to be public. -=item C (boolean) - If set to true, the comment has Markdown -structures, otherwise it is a normal text. - =item C (double) - Adds this many hours to the "Hours Worked" on the bug. If you are not in the time tracking group, this value will be ignored. @@ -3801,11 +3716,6 @@ You tried to add a private comment, but don't have the necessary rights. You tried to add a comment longer than the maximum allowed length (65,535 characters). -=item 140 (Markdown Disabled) - -You tried to set the C flag to true but the Markdown feature -is not enabled. - =back =item B @@ -3828,8 +3738,6 @@ code of 32000. =item REST API call added in Bugzilla B<5.0>. -=item C option added in Bugzilla B<5.0>. - =back =back diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm index db50611cb..d612ebc75 100644 --- a/Bugzilla/WebService/Constants.pm +++ b/Bugzilla/WebService/Constants.pm @@ -101,7 +101,6 @@ use constant WS_ERROR_CODE => { comment_id_invalid => 111, comment_too_long => 114, comment_invalid_isprivate => 117, - markdown_disabled => 140, # Comment tagging comment_tag_disabled => 125, comment_tag_invalid => 126, -- cgit v1.2.1