From 44f458d5770c03c507299a400775296cc2f5eebb Mon Sep 17 00:00:00 2001 From: Jaiwanth Date: Mon, 21 Jun 2021 11:43:47 +0530 Subject: [PATCH] Modify local avatar's url to not contain colons --- src/components/views/avatars/MemberAvatar.tsx | 2 +- src/utils/exportUtils/HtmlExport.tsx | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/views/avatars/MemberAvatar.tsx b/src/components/views/avatars/MemberAvatar.tsx index 48bf0d3423..7488616fb6 100644 --- a/src/components/views/avatars/MemberAvatar.tsx +++ b/src/components/views/avatars/MemberAvatar.tsx @@ -68,7 +68,7 @@ export default class MemberAvatar extends React.Component { private static getState(props: IProps): IState { if (props.member?.name) { let imageUrl = null; - if (props.forExport && props.member.getMxcAvatarUrl()) imageUrl = "AvatarForExport"; + if (props.forExport && props.member.getMxcAvatarUrl()) imageUrl = "avatarForExport"; else if (props.member.getMxcAvatarUrl()) { imageUrl = mediaFromMxc(props.member.getMxcAvatarUrl()).getThumbnailOfSourceHttp( props.width, diff --git a/src/utils/exportUtils/HtmlExport.tsx b/src/utils/exportUtils/HtmlExport.tsx index c1b2f4ea70..b5df531721 100644 --- a/src/utils/exportUtils/HtmlExport.tsx +++ b/src/utils/exportUtils/HtmlExport.tsx @@ -217,7 +217,7 @@ export default class HTMLExporter extends Exporter { this.avatars.set(member.userId, true); const image = await fetch(avatarUrl); const blob = await image.blob(); - this.zip.file(`users/${member.userId}`, blob); + this.zip.file(`users/${member.userId.replace(/:/g, '-')}`, blob); } } @@ -265,7 +265,10 @@ export default class HTMLExporter extends Exporter { let eventTileMarkup = renderToStaticMarkup(eventTile); if (filePath) eventTileMarkup = eventTileMarkup.replace(/(src=|href=)"forExport"/g, `$1"${filePath}"`); if (hasAvatar) { - eventTileMarkup = eventTileMarkup.replace(/src="AvatarForExport"/g, `src="users/${mxEv.sender.userId}"`); + eventTileMarkup = eventTileMarkup.replace( + /src="avatarForExport"/g, + `src="users/${mxEv.sender.userId.replace(/:/g, "-")}"`, + ); } return eventTileMarkup; } @@ -291,8 +294,8 @@ export default class HTMLExporter extends Exporter { formatted_body: `${this.mediaOmitText}`, } if (mxEv.isEncrypted()) { - mxEv._clearEvent.content = modifiedContent; - mxEv._clearEvent.type = "m.room.message"; + mxEv.clearEvent.content = modifiedContent; + mxEv.clearEvent.type = "m.room.message"; } else { mxEv.event.content = modifiedContent; mxEv.event.type = "m.room.message";