From a77c3d4d9b6d550419916275bb2ed9409caa59fd Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Wed, 10 Apr 2019 18:00:04 +0100 Subject: [PATCH 1/5] Prevent user pills containing only emoji from embiggening --- src/HtmlUtils.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index 3315e86e71..3e3138fe66 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -516,7 +516,10 @@ export function bodyToHtml(content, highlights, opts={}) { contentBodyTrimmed = contentBodyTrimmed.replace(ZWJ_REGEX, ''); const match = EMOJI_REGEX.exec(contentBodyTrimmed); - emojiBody = match && match[0] && match[0].length === contentBodyTrimmed.length; + emojiBody = match && match[0] && match[0].length === contentBodyTrimmed.length + // Prevent user pills expanding for users with only emoji in + // their username + && content.formatted_body == undefined; } const className = classNames({ From 6a41975826e672d1ffe0ec8ed6259b05b3a88045 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Wed, 10 Apr 2019 23:34:09 +0100 Subject: [PATCH 2/5] Specific check for user pills --- src/HtmlUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index 3e3138fe66..ae307694f1 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -519,7 +519,7 @@ export function bodyToHtml(content, highlights, opts={}) { emojiBody = match && match[0] && match[0].length === contentBodyTrimmed.length // Prevent user pills expanding for users with only emoji in // their username - && content.formatted_body == undefined; + && !content.formatted_body.includes("https://matrix.to/"); } const className = classNames({ From 52facdc0c361304e10373b871ba0755d0abb5c8d Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 11 Apr 2019 00:05:04 +0100 Subject: [PATCH 3/5] Don't act on undefined attributes --- src/HtmlUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index ae307694f1..f85fc9bc5e 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -519,7 +519,7 @@ export function bodyToHtml(content, highlights, opts={}) { emojiBody = match && match[0] && match[0].length === contentBodyTrimmed.length // Prevent user pills expanding for users with only emoji in // their username - && !content.formatted_body.includes("https://matrix.to/"); + && (content.formatted_body && !content.formatted_body.includes("https://matrix.to/")); } const className = classNames({ From be02f67eeffb2238e4434ffb081c7739090c9e3b Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 11 Apr 2019 00:09:38 +0100 Subject: [PATCH 4/5] Switch logic --- src/HtmlUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index f85fc9bc5e..bde3978677 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -519,7 +519,7 @@ export function bodyToHtml(content, highlights, opts={}) { emojiBody = match && match[0] && match[0].length === contentBodyTrimmed.length // Prevent user pills expanding for users with only emoji in // their username - && (content.formatted_body && !content.formatted_body.includes("https://matrix.to/")); + && (!content.formatted_body || !content.formatted_body.includes("https://matrix.to/")); } const className = classNames({ From 8398e5dd71de8a973be3b718bd10be43bd144302 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 11 Apr 2019 00:42:27 +0100 Subject: [PATCH 5/5] Appease CI --- src/HtmlUtils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/HtmlUtils.js b/src/HtmlUtils.js index bde3978677..d9d8bac93b 100644 --- a/src/HtmlUtils.js +++ b/src/HtmlUtils.js @@ -519,7 +519,8 @@ export function bodyToHtml(content, highlights, opts={}) { emojiBody = match && match[0] && match[0].length === contentBodyTrimmed.length // Prevent user pills expanding for users with only emoji in // their username - && (!content.formatted_body || !content.formatted_body.includes("https://matrix.to/")); + && (content.formatted_body == undefined + || !content.formatted_body.includes("https://matrix.to/")); } const className = classNames({