Skip to content

Commit e4ac9d6

Browse files
committed
Don't quote comma in TSV export (fix #1238)
1 parent bdc28bc commit e4ac9d6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Display uneditable fields in edit form
88
- Shorten all but numeric and date types in select
99
- Fix escaping spaces in cookie value (bug #1208)
10+
- Don't quote comma in TSV export (bug #1238)
1011
- MariaDB: don't display checks with the same name from another table (bug #1135)
1112
- PostgreSQL: Offer foreign keys in create table
1213
- PostgreSQL: Add missing parentheses to CHECK export

adminer/include/functions.inc.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,12 +651,13 @@ function dump_headers(string $identifier, bool $multi_table = false): string {
651651
* @param string[] $row
652652
*/
653653
function dump_csv(array $row): void {
654+
$tsv = $_POST["format"] == "tsv";
654655
foreach ($row as $key => $val) {
655-
if (preg_match('~["\n,;\t]|^0.|\.\d*0$~', $val) || $val === "") {
656+
if (preg_match('~["\n]|^0[^.]|\.\d*0$|' . ($tsv ? '\t' : '[,;]|^$') . '~', $val)) {
656657
$row[$key] = '"' . str_replace('"', '""', $val) . '"';
657658
}
658659
}
659-
echo implode(($_POST["format"] == "csv" ? "," : ($_POST["format"] == "tsv" ? "\t" : ";")), $row) . "\r\n";
660+
echo implode(($_POST["format"] == "csv" ? "," : ($tsv ? "\t" : ";")), $row) . "\r\n";
660661
}
661662

662663
/** Apply SQL function

0 commit comments

Comments
 (0)