From dbbcabfed86d4a155696ebed805cf61000f3b4da Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 12 May 2018 15:57:33 +0100 Subject: [PATCH] switch from asymmetrical fallback form to a cleaner one `mx-reply` Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/HtmlUtils.js | 1 - src/components/views/elements/ReplyThread.js | 26 ++++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index 82b6830b78..58572cf144 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -186,7 +186,6 @@ const sanitizeHtmlParams = { ], allowedAttributes: { // custom ones first: - blockquote: ['data-mx-reply'], // used to allow explicit removal of a reply fallback blockquote, value ignored font: ['color', 'data-mx-bg-color', 'data-mx-color', 'style'], // custom to matrix span: ['data-mx-bg-color', 'data-mx-color', 'style'], // custom to matrix a: ['href', 'name', 'target', 'rel'], // remote target: custom to matrix diff --git a/src/components/views/elements/ReplyThread.js b/src/components/views/elements/ReplyThread.js index cd444fb090..6714de81a4 100644 --- a/src/components/views/elements/ReplyThread.js +++ b/src/components/views/elements/ReplyThread.js @@ -81,7 +81,7 @@ export default class ReplyThread extends React.Component { // Part of Replies fallback support static stripHTMLReply(html) { - return html.replace(/^
[\s\S]+?<\/blockquote>/, ''); + return html.replace(/^[\s\S]+?<\/mx-reply>/, ''); } // Part of Replies fallback support @@ -102,8 +102,8 @@ export default class ReplyThread extends React.Component { switch (ev.getContent().msgtype) { case 'm.text': case 'm.notice': { - html = `
In reply to ${mxid}` - + `
${html || body}
`; + html = `
In reply to ${mxid}` + + `
${html || body}
`; const lines = body.trim().split('\n'); if (lines.length > 0) { lines[0] = `<${mxid}> ${lines[0]}`; @@ -112,28 +112,28 @@ export default class ReplyThread extends React.Component { break; } case 'm.image': - html = `
In reply to ${mxid}` - + `
sent an image.
`; + html = `
In reply to ${mxid}` + + `
sent an image.
`; body = `> <${mxid}> sent an image.\n\n`; break; case 'm.video': - html = `
In reply to ${mxid}` - + `
sent a video.
`; + html = `
In reply to ${mxid}` + + `
sent a video.
`; body = `> <${mxid}> sent a video.\n\n`; break; case 'm.audio': - html = `
In reply to ${mxid}` - + `
sent an audio file.
`; + html = `
In reply to ${mxid}` + + `
sent an audio file.
`; body = `> <${mxid}> sent an audio file.\n\n`; break; case 'm.file': - html = `
In reply to ${mxid}` - + `
sent a file.
`; + html = `
In reply to ${mxid}` + + `
sent a file.
`; body = `> <${mxid}> sent a file.\n\n`; break; case 'm.emote': { - html = `
In reply to * ` - + `${mxid}
${html || body}
`; + html = `
In reply to * ` + + `${mxid}
${html || body}
`; const lines = body.trim().split('\n'); if (lines.length > 0) { lines[0] = `* <${mxid}> ${lines[0]}`;