title: magento escape string for JavaScript part 2
body: <p>This is a follow up on
  <a href="https://stackoverflow.com/questions/4771036/magento-escape-string-for-javascript">magento escape string for javascript</a></p>
  
  <p>where I accepted @AlanStorm suggestion to use json_encode to escape string literals.</p>
  
  <p>But I now have a new problem with this solution.</p>
  
  <p>when trying to escape a URL that has /'s in it to be rendered as a string literal for JavaScript json_encode seems to add redundant \'s in front of the /'s.</p>
  
  <p>Any new suggestions here?</p>
  
  <p>solutions should take a string variable and return a string that would properly be evaluated to a string literal in JavaScript. (I don't care if its surrounded with single or double quotes - although I prefer single quotes. And it must also support newlines in the string.)</p>
  
  <p>Thanks</p>