Title: Code mangling on script use in messages/error handling.
Last modified: August 22, 2016

---

# Code mangling on script use in messages/error handling.

 *  Resolved [DAE](https://wordpress.org/support/users/motionrotation/)
 * (@motionrotation)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/code-mangling-on-script-use-in-messageserror-handling/)
 * A client of mine accidentally inserted the following into the ‘single opt-in 
   message box’ with the outcome that everything after ‘; var doubleOptinMessage
   was output as plain text including \\n from shortcode_form.php:40:187
 * This is allowed by HTML5 so should really be handled.
 * More of a bug report than a request for help, already handling other ways of 
   including follow buttons, etc.
 *     ```
       <a class="twitter-follow-button" href="https://twitter.com/BlankPageSTL" data-show-count="false" data-size="large">Follow [removed]</a>
       <script>// <![CDATA[
       !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?\'http\':\'https\';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\'://platform.twitter.com/widgets.js\';fjs.parentNode.insertBefore(js,fjs);}}(document, \'script\', \'twitter-wjs\');
       // ]]></script>
       <div class="fb-follow" data-href="https://www.facebook.com/[removed]" data-width="150" data-colorscheme="light" data-layout="standard" data-show-faces="true"></div>
       ```
   
 * [https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/](https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/)

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

 *  Thread Starter [DAE](https://wordpress.org/support/users/motionrotation/)
 * (@motionrotation)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/code-mangling-on-script-use-in-messageserror-handling/#post-5522854)
 * Or was it the DIVs? Wouldn’t be a bug then but still worth handling as WP won’t
   reject it as content.
 * Scuse me, brain fried.
 *  Thread Starter [DAE](https://wordpress.org/support/users/motionrotation/)
 * (@motionrotation)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/code-mangling-on-script-use-in-messageserror-handling/#post-5523011)
 * Further update, there’s still some mangling for intents and purposes. JSMin really
   doesn’t like it when you remove `\r`, seems to only properly recognise UNIX newline
   formatting.
 * I’ve seen the exception disappear in my logs with by changing
 *     ```
       var singleOptinMessage = '<?php echo str_replace( '\'' , '"' , preg_replace('/\r?\n/', '\\n', apply_filters('yks_mc_content' , $this->optionVal['single-optin-message']))); ?>';
       var doubleOptinMessage = '<?php echo str_replace( '\'' , '"' , preg_replace('/\r?\n/', '\\n', apply_filters('yks_mc_content' , $this->optionVal['double-optin-message']))); ?>';
       ```
   
 * to
 *     ```
       var singleOptinMessage = '<?php echo str_replace( array('\'',"\r","\n") , array('"',"\\r","\\n"), apply_filters('yks_mc_content' , $this->optionVal['single-optin-message'])); ?>';
       var doubleOptinMessage = '<?php echo str_replace( array('\'',"\r","\n") , array('"',"\\r","\\n"), apply_filters('yks_mc_content' , $this->optionVal['double-optin-message'])); ?>';
       ```
   
 * Not certain if this breaks anything yet but we’ll see.
 *  Plugin Author [Evan Herman](https://wordpress.org/support/users/eherman24/)
 * (@eherman24)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/code-mangling-on-script-use-in-messageserror-handling/#post-5523019)
 * Hi MotionRotation,
 * Thanks for the bug report. I’ll have a look at what might be causing issues. 
   We’re just gearing up for a 5.2 release, so I will look into implementing this
   fix into the next release.
 * The opt in message box is a standard wp_editor, so it may be an issue with how
   wp_editor handles the script code.
 * Are you trying to add follow/share buttons to the confirmation response?
 * Thanks,
    Evan
 *  Thread Starter [DAE](https://wordpress.org/support/users/motionrotation/)
 * (@motionrotation)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/code-mangling-on-script-use-in-messageserror-handling/#post-5523025)
 * Hi,
 * Thanks for getting back.
 * It’s something a client did when trying to add buttons, removed now (as it redirects
   to another page anyway, no point). The problem seems to be ocurring in some fashion
   anyway with a single line of text in <p> tags. I haven’t looked in depth at what
   your parsing code does so I can only say for this use case that I hadn’t pinned
   it down immediately as it appeared fixed until I went to change something in 
   the theme. Still need to solve the problem that had me looking in the logs actually.
 * This isn’t something that’s going to happen all the time but it does cause JSMin(
   in this case called by Autoptimizer but also default for W3 Total Cache) to throw
   an exception. It seems to be very particular about what it accepts as a newline.
 *  Plugin Author [Evan Herman](https://wordpress.org/support/users/eherman24/)
 * (@eherman24)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/code-mangling-on-script-use-in-messageserror-handling/#post-5523139)
 * Hi MotionRotation,
 * We just rolled out v5.2, which includes the fix you have mentioned above. Please
   let us know if you run into issues with the new version.
 * Thanks,
    Evan

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

The topic ‘Code mangling on script use in messages/error handling.’ is closed to
new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/yikes-inc-easy-mailchimp-extender_a1c7e5.
   svg)
 * [Easy Forms for Mailchimp](https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/)
 * [Active Topics](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/reviews/)

## Tags

 * [html5](https://wordpress.org/support/topic-tag/html5/)
 * [script](https://wordpress.org/support/topic-tag/script/)
 * [tags](https://wordpress.org/support/topic-tag/tags/)

 * 5 replies
 * 2 participants
 * Last reply from: [Evan Herman](https://wordpress.org/support/users/eherman24/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/code-mangling-on-script-use-in-messageserror-handling/#post-5523139)
 * Status: resolved