From ee4e056125a3f95aff73d887b33932731dd6d2fd Mon Sep 17 00:00:00 2001 From: JC Brand Date: Wed, 24 Nov 2021 21:43:20 +0100 Subject: [PATCH] Fixes #2718: Message is not displayed if it contains an invalid URL --- CHANGES.md | 1 + src/templates/hyperlink.js | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b02c2618c..b6248a060 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ - #2423: Could not find dependency "converse-controlbox" for plugin "converse-muc" - #2647: Singleton mode doesn't work - #2704: Send button doesn't work in a multi-user chat +- #2718: Message is not displayed if it contains an invalid URL - #2725: Send new presence status to all connected MUCs - #2728: Not sending headers with upload request - #2733: OMEMO Messages received while client closed not decrypted diff --git a/src/templates/hyperlink.js b/src/templates/hyperlink.js index b82ae5e4a..8955b86f9 100644 --- a/src/templates/hyperlink.js +++ b/src/templates/hyperlink.js @@ -1,5 +1,6 @@ -import { html } from "lit"; +import log from '@converse/headless/log'; import { api } from "@converse/headless/core"; +import { html } from "lit"; function onClickXMPPURI (ev) { ev.preventDefault(); @@ -7,7 +8,13 @@ function onClickXMPPURI (ev) { } export default (uri, url_text) => { - let normalized_url = uri.normalize()._string; + let normalized_url; + try { + normalized_url = uri.normalize()._string; + } catch (e) { + log.error(e); + return url_text; + } const pretty_url = uri._parts.urn ? normalized_url : uri.readable(); const visible_url = url_text || pretty_url; if (!uri._parts.protocol && !normalized_url.startsWith('http://') && !normalized_url.startsWith('https://')) {