diff options
author | Byron Jones <bjones@mozilla.com> | 2013-09-18 16:39:10 +0200 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2013-09-18 16:39:10 +0200 |
commit | 7b756e036dfdf54368d5e7e18dd1cefd53724c12 (patch) | |
tree | dbe2337c83f19cdcc03114bd67c67c6003d3511c /extensions/InlineHistory | |
parent | 710050aa3be5fb6c65d495b54837883298ef743d (diff) | |
download | bugzilla-7b756e036dfdf54368d5e7e18dd1cefd53724c12.tar.gz bugzilla-7b756e036dfdf54368d5e7e18dd1cefd53724c12.tar.xz |
Bug 804990: very long data urls break inline history
Diffstat (limited to 'extensions/InlineHistory')
-rw-r--r-- | extensions/InlineHistory/Extension.pm | 13 | ||||
-rw-r--r-- | extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl | 4 |
2 files changed, 15 insertions, 2 deletions
diff --git a/extensions/InlineHistory/Extension.pm b/extensions/InlineHistory/Extension.pm index f761a9fbd..df7ae9f62 100644 --- a/extensions/InlineHistory/Extension.pm +++ b/extensions/InlineHistory/Extension.pm @@ -18,6 +18,19 @@ our $VERSION = '1.5'; # don't show inline history for bugs with lots of changes use constant MAXIMUM_ACTIVITY_COUNT => 500; +# don't show really long values +use constant MAXIMUM_VALUE_LENGTH => 256; + +sub template_before_create { + my ($self, $args) = @_; + $args->{config}->{FILTERS}->{ih_short_value} = sub { + my ($str) = @_; + return length($str) <= MAXIMUM_VALUE_LENGTH + ? $str + : substr($str, 0, MAXIMUM_VALUE_LENGTH - 3) . '...'; + }; +} + sub template_before_process { my ($self, $args) = @_; my $file = $args->{'file'}; diff --git a/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl b/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl index 6debea594..079af95f0 100644 --- a/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl +++ b/extensions/InlineHistory/template/en/default/hook/bug/comments-aftercomments.html.tmpl @@ -137,7 +137,7 @@ [%~%]<a href="[% value FILTER html FILTER js %]" target="_blank" [%~ ' onclick="return inline_history.confirmUnsafeUrl(this.href)"' UNLESS is_safe_url(value) %]> - [%~%][% value FILTER html FILTER js %]</a> + [%~%][% value FILTER ih_short_value FILTER html FILTER js %]</a> [% ELSIF change.fieldname == 'see_also' %] [% FOREACH see_also = value.split(', ') %] [%~%]<a href="[% see_also FILTER html FILTER js %]" target="_blank"> @@ -151,7 +151,7 @@ change.fieldname == 'flagtypes.name' %] [% value FILTER email FILTER js %] [% ELSE %] - [% value FILTER html FILTER js %] + [% value FILTER ih_short_value FILTER html FILTER js %] [% END %] [%~ %]'; [% END %] |