diff --git a/src/HtmlUtils.tsx b/src/HtmlUtils.tsx index ef5ac383e3..1d5defe45d 100644 --- a/src/HtmlUtils.tsx +++ b/src/HtmlUtils.tsx @@ -233,7 +233,7 @@ const transformTags: IExtendedSanitizeOptions["transformTags"] = { // custom to }, }; -const sanitizeHtmlParams: IExtendedSanitizeOptions = { +export const sanitizeHtmlParams: IExtendedSanitizeOptions = { allowedTags: [ 'font', // custom to matrix for IRC-style font coloring 'del', // for markdown diff --git a/src/utils/exportUtils/HtmlExport.ts b/src/utils/exportUtils/HtmlExport.ts index c21f227c35..8e6070cff6 100644 --- a/src/utils/exportUtils/HtmlExport.ts +++ b/src/utils/exportUtils/HtmlExport.ts @@ -8,6 +8,8 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { getUserNameColorClass } from "../FormattingUtils"; import { Exporter } from "./Exporter"; import * as ponyfill from "web-streams-polyfill/ponyfill" +import { sanitizeHtmlParams } from "../../HtmlUtils"; +import sanitizeHtml from "sanitize-html"; const css = ` body { @@ -356,7 +358,7 @@ export default class HTMLExporter extends Exporter { } } - protected async getImageData(event: MatrixEvent) { + protected async getMediaBlob(event: MatrixEvent) { let blob: Blob; try { const isEncrypted = event.isEncrypted(); @@ -369,7 +371,7 @@ export default class HTMLExporter extends Exporter { blob = await image.blob(); } } catch (err) { - console.log("Error decrypting image"); + console.log("Error decrypting media"); } return blob; } @@ -405,21 +407,54 @@ export default class HTMLExporter extends Exporter { let messageBody = ""; switch (event.getContent().msgtype) { case "m.text": - messageBody = `