File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
src/Frontend/src/components/failedmessages Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -129,15 +129,23 @@ async function retrySelected() {
129129 selectedMessages .forEach ((m ) => (m .retryInProgress = true ));
130130}
131131
132- // TODO: this function doesn't work correctly, since any commas in the exception trace breaks the CSV.
133132// Not attempting to use explicit types correctly since this will need to change eventually anyway
134133function exportSelected() {
135134 // eslint-disable-next-line @typescript-eslint/no-explicit-any
136135 function toCSV(array : any []) {
136+ const delimiter = " ," ;
137137 const keys = Object .keys (array [0 ]);
138- let result = keys .join (" \t " ) + " \n " ;
138+ let result = keys .join (delimiter ) + " \n " ;
139139 array .forEach ((obj ) => {
140- result += keys .map ((k ) => obj [k ]).join (" ," ) + " \n " ;
140+ result +=
141+ keys
142+ .map ((k ) => {
143+ let v = String (obj [k ]);
144+ v = v .replaceAll (' "' , ' ""' ); // Escape all double quotes
145+ if (v .search (/ ([",\n ] )/ g ) >= 0 ) v = ` "${v }" ` ; // Quote all values to deal with CR characters
146+ return v ;
147+ })
148+ .join (delimiter ) + " \n " ;
141149 });
142150
143151 return result ;
You can’t perform that action at this time.
0 commit comments