Skip to content

Commit cade8b9

Browse files
committed
Prepend a space to TSV cells that begin with a special character
This ensures applications like Excel treat them as literal strings instead of interpreting them as formulas.
1 parent 04b5694 commit cade8b9

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

share/html/Elements/TSVExport

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ while (my $row = $Collection->Next) {
145145
$val =~ s/(?:\n|\r)+/ /g; $val =~ s{\t}{ }g;
146146
$val = $no_html->scrub($val);
147147
$val = HTML::Entities::decode_entities($val);
148+
# To prevent injection, add a leading space to make sure excel-ish applications treat it like a literal
149+
$val =~ s/^(?=-|\+|=|\@|")/ /;
148150
$val;
149151
} @$col)."\n");
150152
}

0 commit comments

Comments
 (0)