Skip to content

Commit b0cf0b4

Browse files
committed
Escape double quotes per RFC 4180
According to this RFC: 7. If double-quotes are used to enclose fields, then a double-quote appearing inside a field must be escaped by preceding it with another double quote.
1 parent def1295 commit b0cf0b4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

application/libraries/Format.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ public function to_csv()
200200
$output = implode(',', $headings).PHP_EOL;
201201
foreach ($data as &$row)
202202
{
203+
$row = str_replace('"', '""', $row); // Escape dbl quotes per RFC 4180
203204
$output .= '"'.implode('","', $row).'"'.PHP_EOL;
204205
}
205206

@@ -267,4 +268,4 @@ private function _from_serialize($string)
267268

268269
}
269270

270-
/* End of file format.php */
271+
/* End of file format.php */

0 commit comments

Comments
 (0)