]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1279878 - CSV injection
authorDavid Lawrence <dkl@mozilla.com>
Thu, 30 Jun 2016 21:10:14 +0000 (21:10 +0000)
committerDavid Lawrence <dkl@mozilla.com>
Thu, 30 Jun 2016 21:10:19 +0000 (21:10 +0000)
Bugzilla/Template.pm

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