Skip to content

Commit 80fcc9d

Browse files
committed
Quotation marks must be duplicated only when we are working with csv files (Issue 70379)
Issue: 95004
1 parent 843bf9c commit 80fcc9d

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

common/src/main/java/com/genexus/util/DelimitedFilesSafe.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public class DelimitedFilesSafe implements IDelimitedFilesSafe
5050

5151
private String lastLineRead;
5252
private boolean lastFieldRead;
53+
private boolean isCsv;
5354

5455
public String getEncoding()
5556
{
@@ -103,6 +104,7 @@ public byte dfropen(String pfilename, int plen, String pfdel, String psdel, Stri
103104
fdel=pfdel;
104105

105106
sdel = psdel;
107+
this.isCsv = pfilename.toUpperCase().endsWith(".CSV");
106108

107109
try
108110
{
@@ -369,7 +371,7 @@ public byte dfrgtxt(String[] str, int len)
369371
System.err.println("Error ADF0004 o ADF0006");
370372
}
371373

372-
if ((sdel.equals("") || sdel.equals("\"")) && (retstr.contains("\"\"") || (!fdel.equals("") && retstr.contains(fdel))))
374+
if (isCsv && ((sdel.equals("") || sdel.equals("\"")) && (retstr.contains("\"\"") || (!fdel.equals("") && retstr.contains(fdel)))))
373375
{
374376
retstr = retstr.replace("\"\"", "\"");
375377
if (sdel.equals(""))
@@ -630,6 +632,7 @@ public byte dfwopen(final String filename, String fdel, final String sdel, final
630632
this.fdel = fdel;
631633
this.filename = filename;
632634
this.encoding = enc;
635+
this.isCsv = filename.toUpperCase().endsWith(".CSV");
633636

634637
try
635638
{
@@ -957,7 +960,7 @@ private String processStringToWrite(String currToken, int len)
957960
for(int i = 0; i < lenDiff; i++)
958961
currToken = currToken.concat(" ");
959962

960-
if ((sdel.equals("") || sdel.equals("\"")) && (currToken.contains("\"") || (!fdel.equals("") && currToken.contains(fdel)) || currToken.contains(CRLF)))
963+
if (isCsv && ((sdel.equals("") || sdel.equals("\"")) && (currToken.contains("\"") || (!fdel.equals("") && currToken.contains(fdel)) || currToken.contains(CRLF))))
961964
{
962965
currToken = currToken.replace("\"", "\"\"");
963966
if (sdel.equals(""))

0 commit comments

Comments
 (0)