• Resolved wp_kc

    (@wp_kc)


    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

    (@creativejuiz)

    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

    (@wp_kc)

    Fixed!

    Thanks for the speedy response.

    Plugin Author Geoffrey

    (@creativejuiz)

    Definitely thanks to you ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘unescaped javascript string’ is closed to new replies.