diff --git a/src/main/java/app/coronawarn/quicktest/service/CancellationSchedulingService.java b/src/main/java/app/coronawarn/quicktest/service/CancellationSchedulingService.java index 05f9b3bc..a9e5a308 100644 --- a/src/main/java/app/coronawarn/quicktest/service/CancellationSchedulingService.java +++ b/src/main/java/app/coronawarn/quicktest/service/CancellationSchedulingService.java @@ -103,8 +103,8 @@ private void processCsvUploadBatchRecursion(List cancellations) { StringWriter stringWriter = new StringWriter(); CSVWriter csvWriter = - new CSVWriter(stringWriter, '\t', CSVWriter.NO_QUOTE_CHARACTER, - CSVWriter.DEFAULT_ESCAPE_CHARACTER, CSVWriter.DEFAULT_LINE_END); + new CSVWriter(stringWriter, '\t', CSVWriter.DEFAULT_QUOTE_CHARACTER, + '\\', CSVWriter.DEFAULT_LINE_END); StatefulBeanToCsv beanToCsv = new StatefulBeanToCsvBuilder(csvWriter) .build(); diff --git a/src/test/java/app/coronawarn/quicktest/service/CancellationCsvTest.java b/src/test/java/app/coronawarn/quicktest/service/CancellationCsvTest.java index f72ede32..58ab4f10 100644 --- a/src/test/java/app/coronawarn/quicktest/service/CancellationCsvTest.java +++ b/src/test/java/app/coronawarn/quicktest/service/CancellationCsvTest.java @@ -38,6 +38,7 @@ import com.opencsv.CSVParserBuilder; import com.opencsv.CSVReader; import com.opencsv.CSVReaderBuilder; +import com.opencsv.CSVWriter; import com.opencsv.exceptions.CsvException; import java.io.IOException; import java.io.InputStream; @@ -132,7 +133,9 @@ void testCsvExport(int n) throws IOException, NoSuchAlgorithmException, CsvExcep Assertions.assertEquals(getHash(csvBytes), cancellation.getCsvHash()); CSVParser csvParser = new CSVParserBuilder() + .withEscapeChar('\\') .withSeparator('\t') + .withQuoteChar(CSVWriter.DEFAULT_QUOTE_CHARACTER) .build(); try (CSVReader csvReader = new CSVReaderBuilder(new StringReader(csv)) @@ -161,17 +164,17 @@ private QuickTestArchive buildQuickTestArchive(String tenantId) { qta.setConfirmationCwa(Boolean.TRUE); qta.setTestResult(Short.valueOf("6")); qta.setPrivacyAgreement(Boolean.TRUE); - qta.setLastName("last_name"); - qta.setFirstName("first_name"); + qta.setLastName("last\n_na\"me"); + qta.setFirstName("fir\rst_name"); qta.setEmail("email"); qta.setPhoneNumber("phone_number"); qta.setSex(Sex.MALE); qta.setStreet("street"); qta.setHouseNumber("house_number"); qta.setZipCode("zip_code"); - qta.setCity("city"); + qta.setCity("Düßeldorf"); qta.setTestBrandId("test_brand_id"); - qta.setTestBrandName("test_brand_name, Ltd, another_part_of_test_brand_name"); + qta.setTestBrandName("test_brand_name, \"Ltd\", another_part_of_test_brand_name"); qta.setBirthday("2000-01-01"); qta.setPdf("PDF".getBytes()); qta.setTestResultServerHash("test_result_server_hash");