summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/Comment.pm3
-rw-r--r--Bugzilla/Template.pm7
-rw-r--r--Bugzilla/Util.pm25
-rw-r--r--Bugzilla/WebService/Bug.pm7
4 files changed, 38 insertions, 4 deletions
diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm
index 8232f5ac1..7d7ac0d80 100644
--- a/Bugzilla/Comment.pm
+++ b/Bugzilla/Comment.pm
@@ -272,6 +272,9 @@ sub body_full {
else {
$body = $self->body;
}
+ if (!$self->is_markdown and !$self->already_wrapped) {
+ $body = wrap_cite($body);
+ }
if ($params->{wrap} and !$self->already_wrapped) {
$body = wrap_comment($body);
}
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 9398ca4b5..3cbff4733 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -972,6 +972,13 @@ sub create {
return sub { wrap_comment($_[0], $cols) }
}, 1],
+ # Wrap cited text
+ wrap_cite => [
+ sub {
+ my ($context, $cols) = @_;
+ return sub { wrap_cite($_[0], $cols) }
+ }, 1],
+
# We force filtering of every variable in key security-critical
# places; we have a none filter for people to use when they
# really, really don't want a variable to be changed.
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm
index ad008b768..c28c0d05d 100644
--- a/Bugzilla/Util.pm
+++ b/Bugzilla/Util.pm
@@ -18,7 +18,7 @@ use parent qw(Exporter);
i_am_cgi i_am_webservice correct_urlbase remote_ip
validate_ip do_ssl_redirect_if_required use_attachbase
diff_arrays on_main_db
- trim wrap_hard wrap_comment find_wrap_point
+ trim wrap_hard wrap_comment find_wrap_point wrap_cite
format_time validate_date validate_time datetime_from
is_7bit_clean bz_crypt generate_random_password
validate_email_syntax check_email_syntax clean_text
@@ -456,6 +456,27 @@ sub wrap_comment {
return $wrappedcomment;
}
+sub wrap_cite {
+ my ($comment, $cols) = @_;
+ my $wrappedcomment = "";
+
+ # Use 'local', as recommended by Text::Wrap's perldoc.
+ local $Text::Wrap::columns = $cols || COMMENT_COLS;
+ # Make words that are longer than COMMENT_COLS not wrap.
+ local $Text::Wrap::huge = 'overflow';
+ # Don't mess with tabs.
+ local $Text::Wrap::unexpand = 0;
+
+ foreach my $line (split(/\r\n|\r|\n/, $comment)) {
+ if ($line =~ /^(>+ *)/) {
+ $wrappedcomment .= wrap('', $1, $line) . "\n";
+ } else {
+ $wrappedcomment .= $line . "\n";
+ }
+ }
+ return $wrappedcomment;
+}
+
sub find_wrap_point {
my ($string, $maxpos) = @_;
if (!$string) { return 0 }
@@ -1244,4 +1265,6 @@ if Bugzilla is currently using the shadowdb or not. Used like:
=item display_value
+=item wrap_cite
+
=back
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index 84f209347..cc40259f8 100644
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -342,9 +342,10 @@ 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
+ = $params->{markdown}
+ ? '[% text FILTER markdown(bug, { is_markdown => 1 }) %]'
+ : '[% text FILTER wrap_cite FILTER markdown(bug) %]';
my $html;
my $template = Bugzilla->template;
$template->process(