Skip to content

Commit

Permalink
Santize HTML before updating in layout example widget (#1382)
Browse files Browse the repository at this point in the history
* Santize HTML before updating in layout example widget

* none

* none
  • Loading branch information
chrishtr authored Jan 5, 2025
1 parent e35417f commit 7ffcd95
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions www/widgets/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
** purify.min.js:

See license here: `https://github.com/cure53/DOMPurify/blob/main/LICENSE`
1 change: 1 addition & 0 deletions www/widgets/layout-block-container-example.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@
srcdoc=""></iframe>
</flex-item>
</container>
<script type="text/javascript" src="purify.min.js"></script>
<script src="layout-example.js"></script>
5 changes: 3 additions & 2 deletions www/widgets/layout-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ let preamble = `
`;

function updateState() {
targetIframe.srcdoc = `${preamble}${htmlSource.value}`;
var clean = DOMPurify.sanitize(htmlSource.value);
targetIframe.srcdoc = `${preamble}${clean}`;
link.href =
`layout-block-container-example.html?htmlSource=${
encodeURIComponent(htmlSource.value)}`;
encodeURIComponent(clean)}`;
}

onload = () => {
Expand Down
Loading

0 comments on commit 7ffcd95

Please sign in to comment.