From 6fe9fc5813a8dfe10c5f0e92a70751db0678fb7e Mon Sep 17 00:00:00 2001 From: Ryan Olson Date: Wed, 13 Jun 2018 10:23:14 -0500 Subject: [PATCH] manually encode "#" when exporting to csv in firefox, if the csv data has a "#" in it, the file ends at the index of the first occurrence. additionally, encodeURI doesn't encode "#" since it's a valid uri character. --- src/vanilla-dataTables.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vanilla-dataTables.js b/src/vanilla-dataTables.js index e757876..94e749a 100644 --- a/src/vanilla-dataTables.js +++ b/src/vanilla-dataTables.js @@ -2085,6 +2085,8 @@ text = text.replace(/\s{2,}/g, ' '); text = text.replace(/\n/g, ' '); text = text.replace(/"/g, '""'); + //have to manually encode "#" as encodeURI leaves it as is. + text = text.replace(/#/g, "%23"); if (text.indexOf(",") > -1) text = '"' + text + '"';