Title: Javascript code in TCM gets quotes changed
Last modified: July 20, 2022

---

# Javascript code in TCM gets quotes changed

 *  Resolved [andrewmoise](https://wordpress.org/support/users/andrewmoise/)
 * (@andrewmoise)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/javascript-code-in-tcm-gets-quotes-changed/)
 * So if I include in my TCM code block the following code:
 *     ```
       <!-- Special offer timer implementation -->
   
       <script>
       function getCookie(cname) {
           var name = cname + "=";
           var decodedCookie = decodeURIComponent(document.cookie);
           var ca = decodedCookie.split(';');
           for(var i = 0; i <ca.length; i++) {
               var c = ca[i];
               while (c.charAt(0) == ' ') {
                   c = c.substring(1);
               }
               if (c.indexOf(name) == 0) {
                   return c.substring(name.length, c.length);
               }
           }
           return "";
       }
       ```
   
 * (and things continue from there)
 * Then what actually gets expanded into the HTML when my page is served is:
 *     ```
       <script defer="defer">
       function getCookie(cname) {
           var name = cname + "=";
           var decodedCookie = decodeURIComponent(document.cookie);
           var ca = decodedCookie.split(';');
           for(var i = 0; i <ca.length; i++) {
               var c = ca[i];
               while (c.charAt(0) == ' ') {
                   c = c.substring(1);
               }
               if (c.indexOf(name) == 0) {
                   return c.substring(name.length, c.length);
               }
           }
           return &quot;&quot;;
       }
       ```
   
 * So the entity expansion with ampersands causes syntax errors which cause the 
   Javascript not to work… I can just put the Javascript into a separate file but
   it’s easier for me to work being able to edit the short script right in the TCM.
   Is there any way to fix this and still have the code editable in the TCM?
 * Thanks in advance for your help.

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

 *  Plugin Author [Data443 Risk Mitigation, Inc.](https://wordpress.org/support/users/data443/)
 * (@data443)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/javascript-code-in-tcm-gets-quotes-changed/#post-15847276)
 * Hello
 * we are sorry for the inconvenience, we are still working to find a solution for
   this issue.
 * The issue is generated by the comparison operator used in the loop for, it is
   probably mistaken as the start of an html tag and then the PHP function used 
   to sanitize the code goes to clean up everything after it
 * maybe you can invert the comparison operator
 * `for(var i = 0; ca.length>i; i++) {`
 * instead of
 * `for(var i = 0; i<ca.length; i++) {`
 * Could you please edit your script, then check if the javascript function getCookie
   works as expected?
 * Thank you
 *  Plugin Author [Data443 Risk Mitigation, Inc.](https://wordpress.org/support/users/data443/)
 * (@data443)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/javascript-code-in-tcm-gets-quotes-changed/#post-15856850)
 * We’re in the process of fixing this problem and will release an update soon.
 *  Plugin Author [Data443 Risk Mitigation, Inc.](https://wordpress.org/support/users/data443/)
 * (@data443)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/javascript-code-in-tcm-gets-quotes-changed/#post-15861098)
 * Hello [@andrewmoise](https://wordpress.org/support/users/andrewmoise/),
 * Release 2.0.13 fixes the problem you’ve reported here.
 * -Oliver
 *  Thread Starter [andrewmoise](https://wordpress.org/support/users/andrewmoise/)
 * (@andrewmoise)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/javascript-code-in-tcm-gets-quotes-changed/#post-15861414)
 * Hey, that’s excellent! Thank you for the fix + the quick response.

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

The topic ‘Javascript code in TCM gets quotes changed’ is closed to new replies.

 * ![](https://ps.w.org/tracking-code-manager/assets/icon-256x256.jpg?rev=2749278)
 * [Tracking Code Manager](https://wordpress.org/plugins/tracking-code-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tracking-code-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tracking-code-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/tracking-code-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tracking-code-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tracking-code-manager/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 4 replies
 * 2 participants
 * Last reply from: [andrewmoise](https://wordpress.org/support/users/andrewmoise/)
 * Last activity: [3 years, 10 months ago](https://wordpress.org/support/topic/javascript-code-in-tcm-gets-quotes-changed/#post-15861414)
 * Status: resolved