A Pen by Estevão Soares dos Santos on CodePen.
Last active
August 29, 2015 14:24
-
-
Save tivie/5f171f6c30754444ba6b to your computer and use it in GitHub Desktop.
Modern browsers seem to XSS filter element.innerHTML property
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
<button onclick="run()">RUN</button><br> | |
element | |
<div class="box" id="foo"></div> | |
src | |
<textarea class="box" id="fooSrc"></textarea> |
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
function run() { | |
var html = "<a class='some-link' data-bind='click: function(){ someMethod('one', 'two'); }'>two</a>" | |
document.getElementById('foo').innerHTML = html; | |
var foo = document.getElementById('foo').innerHTML; | |
document.getElementById('fooSrc').value = foo; | |
} |
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
.box { | |
display: block; | |
width: 30%; | |
height: 100px; | |
border: 1px solid #ccc; | |
background-color: #eee; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment