Created
August 30, 2016 10:19
-
-
Save gareth-gillman/2faefab6b06c4f39385eece74f41d8cb to your computer and use it in GitHub Desktop.
Checks links on a website for the _blank attribute and adds the noopener and noreferrer tags if they don't exist - see https://dev.to/ben/the-targetblank-vulnerability-by-example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$('a').each(function() { | |
if( | |
$(this).attr('target') == '_blank' || | |
$(this).attr('rel') == 'noopener' || | |
$(this).attr('rel') == 'noreferrer' ) { | |
$(this).attr('rel', 'noopener noreferrer'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment