diff options
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 |