Title: unescaped javascript string
Last modified: April 4, 2021

---

# unescaped javascript string

 *  Resolved [wp_kc](https://wordpress.org/support/users/wp_kc/)
 * (@wp_kc)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/unescaped-javascript-string/)
 * While using developer tools on a web page, I noticed the following javascript…
 * `Uncaught SyntaxError: "" string literal contains an unescaped line break`
 * This error was being caused by the line starting with text: ” in the following
   script generated by your plugin…
 *     ```
       <script>
       	window.addEventListener("DOMContentLoaded", function(){
       		if ( navigator.share ) {
       							let shareurl = document.location.href;
       			let btns = document.querySelectorAll(".juiz_sps_link_shareapi button:not([data-bound])");
       			const canon = document.querySelector("link[rel=canonical]");
   
       			if (canon !== null) {
       				shareurl = canon.href;
       			}
   
       			btns.forEach(function(el) {
       								el.closest(".juiz_sps_link_shareapi").removeAttribute( "style" );
       				el.setAttribute( "data-bound", "true" );
       								el.addEventListener("click", async () => {
       					try {
       						await navigator.share({
       											title: "How To Protect WordPress with CloudFlare Firewall Rules",
       											text: "How To Protect WordPress with CloudFlare Firewall Rules - OVERVIEW
       CloudFlare recently added Firewall Rules to all accounts, including",
       											url: shareurl,
       						});
       										console.info("Successful share");
       					} catch(err) {
       										console.warn("Error sharing", error);
       					}
       				});
       			});
       		}
       	});
       </script>
       ```
   
 * It looks like you could use some esc_js() calls on your javascript string outputs.
 * Thanks.

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

 *  Plugin Author [Geoffrey](https://wordpress.org/support/users/creativejuiz/)
 * (@creativejuiz)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/unescaped-javascript-string/#post-14277960)
 * Thank you for your feedback on this part of the code.
    I did an update right 
   now.
 * If you have a little bit of time to double check if it fixes the issue on your
   side?
    My tests were ok but all the environments are different ;p
 * Thanks a lot!
 *  Thread Starter [wp_kc](https://wordpress.org/support/users/wp_kc/)
 * (@wp_kc)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/unescaped-javascript-string/#post-14280263)
 * Fixed!
 * Thanks for the speedy response.
 *  Plugin Author [Geoffrey](https://wordpress.org/support/users/creativejuiz/)
 * (@creativejuiz)
 * [5 years, 1 month ago](https://wordpress.org/support/topic/unescaped-javascript-string/#post-14361679)
 * Definitely thanks to you 👊

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

The topic ‘unescaped javascript string’ is closed to new replies.

 * ![](https://ps.w.org/juiz-social-post-sharer/assets/icon-256x256.png?rev=3389742)
 * [Nobs • Share Buttons](https://wordpress.org/plugins/juiz-social-post-sharer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/juiz-social-post-sharer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/juiz-social-post-sharer/)
 * [Active Topics](https://wordpress.org/support/plugin/juiz-social-post-sharer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/juiz-social-post-sharer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/juiz-social-post-sharer/reviews/)

## Tags

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

 * 3 replies
 * 2 participants
 * Last reply from: [Geoffrey](https://wordpress.org/support/users/creativejuiz/)
 * Last activity: [5 years, 1 month ago](https://wordpress.org/support/topic/unescaped-javascript-string/#post-14361679)
 * Status: resolved