mirror of
https://github.com/hanzoai/DOMPurify.git
synced 2026-09-24 16:55:05 +00:00
28 lines
901 B
HTML
28 lines
901 B
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<title>DOMPurify demo: Basic usage</title>
|
|
<script src="../dist/purify.js"></script>
|
|
</head>
|
|
<body>
|
|
<!-- Our DIV to receive content -->
|
|
<div id="sanitized"></div>
|
|
|
|
<!-- Now let's sanitize that content -->
|
|
<script>
|
|
'use strict';
|
|
|
|
// Assuming DOMPurify is globally available
|
|
// import DOMPurify from 'dompurify'; // Uncomment if using ES6 modules
|
|
|
|
// Specify dirty HTML
|
|
const dirty = '<p>HELLO<iframe/\/src=JavScript:alert(1)></ifrAMe><br>goodbye</p>';
|
|
|
|
// Clean HTML string and write into our DIV
|
|
const clean = DOMPurify.sanitize(dirty);
|
|
document.getElementById('sanitized').innerHTML = clean;
|
|
</script>
|
|
</body>
|
|
</html>
|