Skip to content

Commit 75f12db

Browse files
Simon Greendklawren
authored andcommitted
Bug 1054702: CSV export vulnerable to formulae injection
r=glob,a=glob
1 parent 19576a8 commit 75f12db

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Bugzilla/Template.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,12 @@ sub create {
730730
},
731731

732732
# In CSV, quotes are doubled, and any value containing a quote or a
733-
# comma is enclosed in quotes.
733+
# comma is enclosed in quotes. If a field starts with an equals
734+
# sign, it is proceed by a space.
734735
csv => sub
735736
{
736737
my ($var) = @_;
738+
$var = ' ' . $var if substr($var, 0, 1) eq '=';
737739
$var =~ s/\"/\"\"/g;
738740
if ($var !~ /^-?(\d+\.)?\d*$/) {
739741
$var = "\"$var\"";

template/en/default/reports/report-table.csv.tmpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@
3939
[% END %]
4040
[% tbl_field_disp FILTER csv %]: [% tbl_disp FILTER csv %]
4141
[% END %]
42-
[% IF row_field %]
42+
[% IF row_field && col_field %]
43+
[% row_field_disp _ ' / ' _ col_field_disp FILTER csv %]
44+
[% ELSIF row_field %]
4345
[% row_field_disp FILTER csv %]
46+
[% ELSE %]
47+
[% col_field_disp FILTER csv %]
4448
[% END %]
45-
[% " / " IF col_field AND row_field %]
46-
[% col_field_disp FILTER csv %]
4749
[% IF col_field -%]
4850
[% FOREACH col = col_names -%]
4951
[% colsepchar %]

0 commit comments

Comments
 (0)