mofosyne / tagdrop

allows for reading datauris, and displaying the media as if it was html or text or sound etc...
GNU General Public License v3.0
14 stars 2 forks source link

javascript in plain/html files does not work if not urlencoded properly. #5

Open mofosyne opened 9 years ago

mofosyne commented 9 years ago
 data:text/html,<pre style=line-height:1><script>d=document;for(i=1;i<4001;i++){d.write(Math.random()<.5?"\u2571":"\u2572");d.write(i%80?"":"\n")}</script>

doesn't work, but this does:

 data:text/html;base64,PHByZSBzdHlsZT1saW5lLWhlaWdodDoxPjxzY3JpcHQ+ZD1kb2N1bWVudDtmb3IoaT0xO2k8NDAwMTtpKyspe2Qud3JpdGUoTWF0aC5yYW5kb20oKTwuNT8iXHUyNTcxIjoiXHUyNTcyIik7ZC53cml0ZShpJTgwPyIiOiJcbiIpfTwvc2NyaXB0Pg==

Btw, this was sourced from https://twitter.com/botond_balazs/status/637960240055615488


This is how firefox errors shows up:

ORIGNAL: <pre style=line-height:1><script>d=document;for(i=1;i<4001;i++){d.write(Math.random()<.5?"\u2571":"\u2572");d.write(i%80?"":"\n")}</script>
PARSED:: <pre style=line-height:1><script>d=document;for(i=1;i<4001;i++){d.write(Math.random()<.5?"\u2571":"\u2572");d.write(i€?"":"\n")}</script>

ANS edit:

https://www.reddit.com/r/programming/comments/3iy6fk/javascript_maze_generator_in_a_tweet/cukpbai

You can make it work via: spacing out out the %80 to % 80

So it was due to mistaking the %80 being a percent encoded character. Thus is something to be aware of.


http://qrfree.kaywa.com/?l=1&s=8&d=data%3Atext%2Fhtml%2C%3Cpre+style%3Dline-height%3A1%3E%3Cscript%3Efor%28i%3D4e3%3Bi--%3B%29document.write%28%28Math.random%28%29%3C.5%3F%22%5Cu2571%22%3A%22%5Cu2572%22%29%2B%28i%25+80%3F%22%22%3A%22%5Cn%22%29%29%3C%2Fscript%3E