This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
stores/room-list/previews Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -130,11 +130,14 @@ export function sanitizedHtmlNode(insaneHtml: string) {
130130 return < div dangerouslySetInnerHTML = { { __html : saneHtml } } dir = "auto" /> ;
131131}
132132
133- export function sanitizedHtmlNodeInnerText ( insaneHtml : string ) {
134- const saneHtml = sanitizeHtml ( insaneHtml , sanitizeHtmlParams ) ;
135- const contentDiv = document . createElement ( "div" ) ;
136- contentDiv . innerHTML = saneHtml ;
137- return contentDiv . innerText ;
133+ export function getHtmlText ( insaneHtml : string ) {
134+ return sanitizeHtml ( insaneHtml , {
135+ allowedTags : [ ] ,
136+ allowedAttributes : { } ,
137+ selfClosing : [ ] ,
138+ allowedSchemes : [ ] ,
139+ disallowedTagsMode : 'discard' ,
140+ } )
138141}
139142
140143/**
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/models/event";
2020import { _t } from "../../../languageHandler" ;
2121import { getSenderName , isSelf , shouldPrefixMessagesIn } from "./utils" ;
2222import ReplyThread from "../../../components/views/elements/ReplyThread" ;
23- import { sanitizedHtmlNodeInnerText } from "../../../HtmlUtils" ;
23+ import { getHtmlText } from "../../../HtmlUtils" ;
2424
2525export class MessageEventPreview implements IPreview {
2626 public getTextFor ( event : MatrixEvent , tagId ?: TagID ) : string {
@@ -55,7 +55,7 @@ export class MessageEventPreview implements IPreview {
5555 }
5656
5757 if ( hasHtml ) {
58- body = sanitizedHtmlNodeInnerText ( body ) ;
58+ body = getHtmlText ( body ) ;
5959 }
6060
6161 if ( msgtype === 'm.emote' ) {
You can’t perform that action at this time.
0 commit comments