From 584b49fc875bff5916894270d97682dfcfc69ed7 Mon Sep 17 00:00:00 2001 From: Puzzleton Date: Mon, 26 Aug 2019 11:07:31 -0500 Subject: [PATCH] Send the original value of the str parameter to the quotes function --- papaparse.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/papaparse.js b/papaparse.js index 331e8cd..9f8a560 100755 --- a/papaparse.js +++ b/papaparse.js @@ -447,17 +447,17 @@ License: MIT if (str.constructor === Date) return JSON.stringify(str).slice(1, 25); - str = str.toString().replace(quoteCharRegex, _escapedQuote); + var escapedQuoteStr = str.toString().replace(quoteCharRegex, _escapedQuote); var needsQuotes = (typeof _quotes === 'boolean' && _quotes) || (typeof _quotes === 'function' && _quotes(str, col)) || (Array.isArray(_quotes) && _quotes[col]) - || hasAny(str, Papa.BAD_DELIMITERS) - || str.indexOf(_delimiter) > -1 - || str.charAt(0) === ' ' - || str.charAt(str.length - 1) === ' '; + || hasAny(escapedQuoteStr, Papa.BAD_DELIMITERS) + || escapedQuoteStr.indexOf(_delimiter) > -1 + || escapedQuoteStr.charAt(0) === ' ' + || escapedQuoteStr.charAt(escapedQuoteStr.length - 1) === ' '; - return needsQuotes ? _quoteChar + str + _quoteChar : str; + return needsQuotes ? _quoteChar + escapedQuoteStr + _quoteChar : escapedQuoteStr; } function hasAny(str, substrings)