mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
SECURITY: Remove XSS in composer preview when applying image scale buttons.
This commit is contained in:
@@ -878,15 +878,13 @@ export default Ember.Component.extend({
|
||||
if ($preview.find(".codeblock-image").length === 0) {
|
||||
this.$(".d-editor-preview *")
|
||||
.contents()
|
||||
.filter(function() {
|
||||
return this.nodeType === 3; // TEXT_NODE
|
||||
})
|
||||
.each(function() {
|
||||
$(this).replaceWith(
|
||||
$(this)
|
||||
.text()
|
||||
.replace(imageScaleRegex, "<span class='codeblock-image'>$&</a>")
|
||||
);
|
||||
if (this.nodeType !== 3) return; // TEXT_NODE
|
||||
const $this = $(this);
|
||||
|
||||
if ($this.text().match(imageScaleRegex)) {
|
||||
$this.wrap("<span class='codeblock-image'></span>");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user