Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#8193 strip commas from email response #8343

Merged
merged 9 commits into from
Jan 25, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ public StringBuilder convertGuestbookResponsesToCSV ( Map<Integer, Object> custo
// string fields, or the structure of the file will be broken. -- L.A.

// Guestbook name:
sb.append(((String)result[1]).replace(',', ' '));
sb.append("\"" + (String)result[1] + "\"");
sb.append(SEPARATOR);


// Dataset name:
Integer datasetId = (Integer) result[2];
String datasetTitle = datasetTitles.get(datasetId);
sb.append(datasetTitle == null ? "" : datasetTitle.replace(',', ' '));
sb.append(datasetTitle == null ? "" : "\"" + datasetTitle + "\"");
sb.append(SEPARATOR);

// Dataset persistent identifier:
Expand All @@ -211,7 +211,7 @@ public StringBuilder convertGuestbookResponsesToCSV ( Map<Integer, Object> custo
sb.append(SEPARATOR);

// file name:
sb.append(((String)result[5]).replace(',', ' '));
sb.append("\"" + (String)result[5] + "\"" );
sb.append(SEPARATOR);

// file id (numeric):
Expand All @@ -224,19 +224,19 @@ public StringBuilder convertGuestbookResponsesToCSV ( Map<Integer, Object> custo
sb.append(SEPARATOR);

// name supplied in the guestbook response:
sb.append(result[7] == null ? "" : ((String)result[7]).replace(',', ' '));
sb.append(result[7] == null ? "" : "\"" + (String)result[7] + "\"");
sb.append(SEPARATOR);

// email:
sb.append(result[8] == null ? "" : result[8]);
sb.append(result[8] == null ? "" : "\"" + (String)result[8] + "\"");
sb.append(SEPARATOR);

// institution:
sb.append(result[9] == null ? "" : ((String)result[9]).replace(',', ' '));
sb.append(result[9] == null ? "" : "\"" + (String)result[9] + "\"");
sb.append(SEPARATOR);

// position:
sb.append(result[10] == null ? "" : ((String)result[10]).replace(',', ' '));
sb.append(result[10] == null ? "" : "\"" + (String)result[10] + "\"");

// Finally, custom questions and answers, if present:

Expand Down Expand Up @@ -401,7 +401,7 @@ private Map<Integer, Object> selectCustomQuestionAnswers(Long dataverseId, Long
if (asString) {
// as combined strings of comma-separated question and answer values

String qa = SEPARATOR + ((String)response[0]).replace(',', ' ') + SEPARATOR + (response[1] == null ? "" : ((String)response[1]).replace(',', ' '));
String qa = SEPARATOR + ("\"" + (String)response[0] + "\"") + SEPARATOR + (response[1] == null ? "" : "\"" + (String)response[1] + "\"");

if (ret.containsKey(responseId)) {
ret.put(responseId, ret.get(responseId) + qa);
Expand Down