Created
February 8, 2018 08:38
-
-
Save bharathvaj-ganesan/f7e945ae953b1b5c01e6f702d511a854 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/0.8.2/purify.min.js"></script> | |
| <script> | |
| function sanitize(strings, ...values) { | |
| const dirty = strings.reduce((prev, next, i) => `${prev}${next}${values[i] || ''}`, ''); | |
| console.log(dirty); | |
| console.log(aboutMe); | |
| return DOMPurify.sanitize(aboutMe); | |
| } | |
| const name = 'petyr baelish'; | |
| const aboutMe = `I love to do evil <img src="http://unsplash.it/100/100?random" onload="alert('I hacked you. Haha');" />`; | |
| const html = sanitize` | |
| <h3>${name}</h3> | |
| <p>${aboutMe}</p> | |
| `; | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment