• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Different Javascript execution in ESTK and Node.js

Enthusiast ,
Nov 23, 2015 Nov 23, 2015

Copy link to clipboard

Copied

I have this function for sanitizing text for JSON output that simplifies different line feed formats and escapes the quotation marks. So far it has worked fine, but now I noticed that when ESTK and Node.js provide different output when executed with a line change:

  • ESTK outputs "\n"
  • Node.js outputs "\\n"


I.e. the string literal gets different treatment, but not sure if that's the Javascript parsing or .replace itself. Thoughts, Ideas?

sanitizeJsonText: function(str) {

  return str.replace(/\r\n/g, "\\n")

  .replace(/\r/g, "\\n")

  .replace(/\n/g, "\\n")

  .replace(/\'/g, "\\'")

  .replace(/\"/g, "\\\"");

},

TOPICS
Actions and scripting

Views

291

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Nov 24, 2015 Nov 24, 2015

Never mind, PBCAK. Issue was duplicate escaping in one code branch that was not used in ESTK that was matched debug printing code duplicating behaviour

Votes

Translate

Translate
Adobe
Enthusiast ,
Nov 24, 2015 Nov 24, 2015

Copy link to clipboard

Copied

LATEST

Never mind, PBCAK. Issue was duplicate escaping in one code branch that was not used in ESTK that was matched debug printing code duplicating behaviour

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines