gradio-pr-bot commited on
Commit
133dee5
·
verified ·
1 Parent(s): da981d7

Upload folder using huggingface_hub

Browse files
6.24.0/workflowcanvas/workflow/NodeWidget.svelte CHANGED
@@ -117,7 +117,18 @@
117
  );
118
 
119
  function openHtmlInTab(html: string): void {
120
- const blob = new Blob([html], { type: "text/html" });
 
 
 
 
 
 
 
 
 
 
 
121
  const url = URL.createObjectURL(blob);
122
  window.open(url, "_blank", "noopener");
123
  setTimeout(() => URL.revokeObjectURL(url), 60_000);
 
117
  );
118
 
119
  function openHtmlInTab(html: string): void {
120
+ // A Blob URL inherits the origin of whoever created it, so opening this
121
+ // HTML directly would run model-authored markup as the app itself. Host it
122
+ // in a sandboxed iframe instead, which is the same opaque origin the
123
+ // in-page preview gives it.
124
+ const srcdoc = html.replace(/&/g, "&").replace(/"/g, """);
125
+ const wrapper =
126
+ `<!doctype html><html><head><meta charset="utf-8">` +
127
+ `<title>HTML preview</title>` +
128
+ `<style>html,body{margin:0;height:100%}iframe{border:0;width:100%;height:100%}</style>` +
129
+ `</head><body><iframe sandbox="allow-scripts" srcdoc="${srcdoc}"` +
130
+ ` title="HTML preview"></iframe></body></html>`;
131
+ const blob = new Blob([wrapper], { type: "text/html" });
132
  const url = URL.createObjectURL(blob);
133
  window.open(url, "_blank", "noopener");
134
  setTimeout(() => URL.revokeObjectURL(url), 60_000);