From 363f107191c2a2042a38b0f36026eb21282e6044 Mon Sep 17 00:00:00 2001 From: Juuso Lapinlampi Date: Sun, 4 Oct 2015 15:54:59 +0000 Subject: Wrap CSV response values in double quotes (") While double quotes are mostly optional in implementations, some CSV linters want double quotes for whatever the reason. Assumably, it reduces the amount of bugs and avoids possible parsing errors. This also has very little relevance for not trusting the user input, but better be safe than sorry. This commit is not very pretty. In a future commit, this issue will be addressed with arrays and fputcsv(). --- static/classes/Response.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'static/classes/Response.class.php') diff --git a/static/classes/Response.class.php b/static/classes/Response.class.php index e44652a..4e28678 100755 --- a/static/classes/Response.class.php +++ b/static/classes/Response.class.php @@ -104,17 +104,17 @@ class Response private static function csv_error($description) { - return "error\r\n".$description."\r\n"; + return '"error"'."\r\n"."\"$description\""."\r\n"; } private static function csv_success($files) { - $result = "name,url,hash,size\r\n"; + $result = '"name","url","hash","size"'."\r\n"; foreach ($files as $file) { - $result .= $file['name'].','. - $file['url'].','. - $file['hash'].','. - $file['size']."\r\n"; + $result .= '"'.$file['name'].'"'.','. + '"'.$file['url'].'"'.','. + '"'.$file['hash'].'"'.','. + '"'.$file['size'].'"'."\r\n"; } return $result; -- cgit v1.2.3