Quotationmarks in Data Fields not escaped
Closed this issue · 3 comments
If an "Artist Name(s)" field contains Double quotation marks ("), they will not be escaped. This will corrupt the .csv file.
So far I have only been able to produce this behaviour in "Artist Name(s)", but it is most likely a general problem.
For example
Broken: Royce Da 5'9"
Track ID,Track Name,Album Name,Artist Name(s),Release Date,Duration (ms),Popularity,Added By,Added At,Genres,Record Label, Danceability,Energy,Key,Loudness,Mode,Speechiness,Acousticness,Instrumentalness,Liveness,Valence,Tempo,Time Signature
3CJbxqRQ0JNCqboWDNUUeX,"I Will (feat. KXNG Crooked, Royce Da 5'9 & Joell Ortiz)","Music To Be Murdered By","Eminem,KXNG Crooked,Royce Da 5'9",Joell Ortiz",2020-01-17,303000,48,z6eby17xvrh974c18bxx5fgv0,2024-02-24T16:06:00Z,"detroit hip hop,hip hop,rap,cali rap,gangster rap,hardcore hip hop,battle rap","Shady/Aftermath/Interscope Records",0.635,0.543,8,-5.941,1,0.067,0.0454,0.000678,0.272,0.036,98.743,4
This could be fixed by escaping with another Double Quotation Mark ( "" )
Fixed: Royce Da 5'9""
Track ID,Track Name,Album Name,Artist Name(s),Release Date,Duration (ms),Popularity,Added By,Added At,Genres,Record Label, Danceability,Energy,Key,Loudness,Mode,Speechiness,Acousticness,Instrumentalness,Liveness,Valence,Tempo,Time Signature
3CJbxqRQ0JNCqboWDNUUeX,"I Will (feat. KXNG Crooked, Royce Da 5'9 & Joell Ortiz)","Music To Be Murdered By","Eminem,KXNG Crooked,Royce Da 5'9"",Joell Ortiz",2020-01-17,303000,48,z6eby17xvrh974c18bxx5fgv0,2024-02-24T16:06:00Z,"detroit hip hop,hip hop,rap,cali rap,gangster rap,hardcore hip hop,battle rap","Shady/Aftermath/Interscope Records",0.635,0.543,8,-5.941,1,0.067,0.0454,0.000678,0.272,0.036,98.743,4
Good catch. Not sure how common an issue this is. I'll eventually fix it, but I'm no longer on a coding tear for this repo. I'd accept a PR quicker. I escape characters in several fields, so maybe it's just a matter of applying that same logic to artist names? Not sure whether I was already trying to treat artist names carefully this way; I'll have to look at the code. It'll be deep in the readCsv
function.
It wasn't really a general problem, because I'm already dealing with it on line 204 of exportify.js by calling ?.replace(/"/g,'')
on song names and album names. This just wipes out the double quotes so they don't interfere with the .csv, slightly corrupting names which contain quotes in the process. I regard this as acceptable, because "
is a pretty rare character to find in names. I've gone and added this same logic to artist names: 7fbe761. Does it work for you now, @Jnns3001?
Would adding \
before "
also work to fix the .csv? Would this be preferable? Those names would come out also looking a bit odd/corrupted in the end.