• Resolved cwdg

    (@cwdg)


    WordFence adds the javascript below when bots check the site. The issue is that this script now causes errors/warnings on all the code validation sites when checking HTML5. The issue is that type="text/javascript is no longer needed and is considered an invalid attribute.

    Is there a filter or method in which I can remove the type attribute from the script tag?

    <script type="text/javascript">↩
    (function(url){↩
    	if(/(?:Chrome\/26\.0\.1410\.63 Safari\/537\.31|WordfenceTestMonBot)/.test(navigator.userAgent)){ return; }↩
    	var addEvent = function(evt, handler) {↩
    		if (window.addEventListener) {↩
    			document.addEventListener(evt, handler, false);↩
    		} else if (window.attachEvent) {↩
    			document.attachEvent('on' + evt, handler);↩
    		}↩
    	};↩
    	var removeEvent = function(evt, handler) {↩
    		if (window.removeEventListener) {↩
    			document.removeEventListener(evt, handler, false);↩
    		} else if (window.detachEvent) {↩
    			document.detachEvent('on' + evt, handler);↩
    		}↩
    	};↩
    	var evts = 'contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop keydown keypress keyup mousedown mousemove mouseout mouseover mouseup mousewheel scroll'.split(' ');↩
    	var logHuman = function() {↩
    		if (window.wfLogHumanRan) { return; }↩
    		window.wfLogHumanRan = true;↩
    		var wfscr = document.createElement('script');↩
    		wfscr.type = 'text/javascript';↩
    		wfscr.async = true;↩
    		wfscr.src = url + '&r=' + Math.random();↩
    		(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(wfscr);↩
    		for (var i = 0; i < evts.length; i++) {↩
    			removeEvent(evts[i], logHuman);↩
    		}↩
    	};↩
    	for (var i = 0; i < evts.length; i++) {↩
    		addEvent(evts[i], logHuman);↩
    	}↩
    })('//www.cwdgservices.com/?wordfence_lh=1&hid=D0BE414EEAD6F006FED4068FEC5077F8');↩
    </script>
    • This topic was modified 7 years, 10 months ago by cwdg.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support wfphil

    (@wfphil)

    Hi,

    You will notice that WordPress itself also adds the type attribute to inline JavaScript and CSS.

    The script we load for detecting human visitors is created with document.createElement(‘script’) so how that ends up being constructed would depend on the browser.

    It has been discussed here for your interest:

    https://core.trac.wordpress.org/ticket/42804

    Plugin Support wfphil

    (@wfphil)

    Hi,

    I have opened a bug case that if WordPress implements HTML 5 compliant inline JavaScript tags then we may consider doing the same.

    Thanks.

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

The topic ‘Wordfence Bot JS causing validation errors’ is closed to new replies.