Title: Javascript syntax error when caption has double quotes
Last modified: August 20, 2016

---

# Javascript syntax error when caption has double quotes

 *  Resolved [Chris Jean](https://wordpress.org/support/users/chrisjean/)
 * (@chrisjean)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/javascript-syntax-error-when-caption-has-double-quotes/)
 * When a caption has one or more double quotes in it, the MP3J_PLAYLISTS variable
   will contain syntax errors due to the unescaped quote. I found that the MP3j_Main::
   compare_swap function escaped the titles entry but not the artists entry, thus
   causing the issue. I have a patch [here](http://gaarai.com/temp/fix-unescaped-quotes-in-playlist-js.diff)
   that shows how the same escaping can be used to fix the issue for captions.
 * I should note that you can use the [json_encode](http://www.php.net/manual/en/function.json-encode.php)
   function to generate fully-valid Javascript data structures from a PHP data structure.
   This would be a much easier way to generate this output rather than hand building
   it and possibly creating unknown syntax error conditions based on user input.
   You would have to restructure your functions to simply return data structures
   to be fed into the json_encode function, but it would help avoid future issues
   such as this.
 * [http://wordpress.org/extend/plugins/mp3-jplayer/](http://wordpress.org/extend/plugins/mp3-jplayer/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [simon.ward](https://wordpress.org/support/users/simonward-1/)
 * (@simonward-1)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/javascript-syntax-error-when-caption-has-double-quotes/#post-3489095)
 * Thanks Chris, will be fixed for next time.
 *  Thread Starter [Chris Jean](https://wordpress.org/support/users/chrisjean/)
 * (@chrisjean)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/javascript-syntax-error-when-caption-has-double-quotes/#post-3489101)
 * Glad to hear Simon. Thanks for checking on it.
 *  Plugin Author [simon.ward](https://wordpress.org/support/users/simonward-1/)
 * (@simonward-1)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/javascript-syntax-error-when-caption-has-double-quotes/#post-3489184)
 * Should now be fixed (version 1.8.3)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Javascript syntax error when caption has double quotes’ is closed to 
new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/mp3-jplayer_c3a59d.svg)
 * [MP3-jPlayer](https://wordpress.org/plugins/mp3-jplayer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mp3-jplayer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mp3-jplayer/)
 * [Active Topics](https://wordpress.org/support/plugin/mp3-jplayer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mp3-jplayer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mp3-jplayer/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [simon.ward](https://wordpress.org/support/users/simonward-1/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/javascript-syntax-error-when-caption-has-double-quotes/#post-3489184)
 * Status: resolved