mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 20:22:45 +08:00
Merge pull request from GHSA-vw39-6w7q-gfx5
Co-authored-by: Robin Ward <robin.ward@gmail.com>
This commit is contained in:
parent
87f15f9ed6
commit
337b823ec6
|
@ -0,0 +1,19 @@
|
||||||
|
import Component from "@ember/component";
|
||||||
|
|
||||||
|
export default Component.extend({
|
||||||
|
tagName: "iframe",
|
||||||
|
html: null,
|
||||||
|
className: "",
|
||||||
|
classNameBindings: ["html:iframed-html", "className"],
|
||||||
|
sandbox: "allow-same-origin",
|
||||||
|
attributeBindings: ['sandbox:sandbox'],
|
||||||
|
|
||||||
|
didRender() {
|
||||||
|
this._super(...arguments);
|
||||||
|
const iframeDoc = this.element.contentWindow.document;
|
||||||
|
iframeDoc.open("text/html", "replace");
|
||||||
|
iframeDoc.write(this.html);
|
||||||
|
iframeDoc.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -37,9 +37,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if showHtmlPart}}
|
{{#if showHtmlPart}}
|
||||||
<div class="incoming-email-html-part">
|
{{iframed-html html=htmlPart className="incoming-email-html-part"}}
|
||||||
{{{htmlPart}}}
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/d-modal-body}}
|
{{/d-modal-body}}
|
||||||
|
|
|
@ -494,8 +494,14 @@
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
}
|
}
|
||||||
.incoming-email-html-part {
|
.incoming-email-html-part {
|
||||||
|
width: calc(100% - 36px);
|
||||||
padding: 10px 4px 4px 4px;
|
padding: 10px 4px 4px 4px;
|
||||||
}
|
}
|
||||||
|
@media screen and (max-width: 760px) {
|
||||||
|
.incoming-email-html-part {
|
||||||
|
width: calc(100% - 10px);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
.iframed-html {
|
||||||
|
background: white;
|
||||||
|
border: none;
|
||||||
|
}
|
23
test/javascripts/components/iframed-html-test.js.es6
Normal file
23
test/javascripts/components/iframed-html-test.js.es6
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import componentTest from "helpers/component-test";
|
||||||
|
|
||||||
|
moduleForComponent("iframed-html", { integration: true });
|
||||||
|
|
||||||
|
componentTest("appends the html into the iframe", {
|
||||||
|
template: `{{iframed-html html="<h1 id='find-me'>hello</h1>" className='this-is-an-iframe'}}`,
|
||||||
|
|
||||||
|
async test(assert) {
|
||||||
|
const iframe = find("iframe.this-is-an-iframe");
|
||||||
|
assert.equal(iframe.length, 1, "inserts an iframe");
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
iframe[0].classList.contains("this-is-an-iframe"),
|
||||||
|
"Adds className to the iframes classList"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
iframe[0].contentWindow.document.body.querySelectorAll("#find-me").length,
|
||||||
|
1,
|
||||||
|
"inserts the passed in html into the iframe"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user