Skip to content

Commit 36253a7

Browse files
committed
Bug 1259881 - CSV export vulnerable to formulae injection (again)
r=sgreen a=dkl
1 parent 94d623c commit 36253a7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Bugzilla/Template.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,12 +713,13 @@ sub create {
713713
},
714714

715715
# In CSV, quotes are doubled, and any value containing a quote or a
716-
# comma is enclosed in quotes. If a field starts with an equals
717-
# sign, it is proceed by a space.
716+
# comma is enclosed in quotes.
717+
# If a field starts with either "=", "+", "-" or "@", it is preceded
718+
# by a space to prevent stupid formula execution from Excel & co.
718719
csv => sub
719720
{
720721
my ($var) = @_;
721-
$var = ' ' . $var if substr($var, 0, 1) eq '=';
722+
$var = ' ' . $var if $var =~ /^[+=@-]/;
722723
# backslash is not special to CSV, but it can be used to confuse some browsers...
723724
# so we do not allow it to happen. We only do this for logged-in users.
724725
$var =~ s/\\/\x{FF3C}/g if Bugzilla->user->id;

0 commit comments

Comments
 (0)