diff options
author | Albert Ting <altlist@gmail.com> | 2016-01-02 22:20:22 +0100 |
---|---|---|
committer | Dylan Hardison <dylan@mozilla.com> | 2016-01-02 22:21:04 +0100 |
commit | 8f405c09b2ef1db943aaea9201785d93cd35f86e (patch) | |
tree | 41de3a0f1df48d48a27a77f3d2520b02768d47b7 /Bugzilla/Util.pm | |
parent | 85ca54b444cb0da4d83e23f0235b6a6f31858119 (diff) | |
download | bugzilla-8f405c09b2ef1db943aaea9201785d93cd35f86e.tar.gz bugzilla-8f405c09b2ef1db943aaea9201785d93cd35f86e.tar.xz |
Bug 688205 - quoted text inside comments should wrap
r=dylan,a=dylan
Diffstat (limited to 'Bugzilla/Util.pm')
-rw-r--r-- | Bugzilla/Util.pm | 25 |
1 files changed, 24 insertions, 1 deletions
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 |