From b9f035790d63e6092760514b2fab94da5ec1cd25 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Thu, 15 Jun 2023 22:07:29 +1200 Subject: [PATCH 1/2] UI: More accurate clickable hyperlink logic in plain text messages See #125 --- server/ui-src/templates/Message.vue | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/server/ui-src/templates/Message.vue b/server/ui-src/templates/Message.vue index f212f4b..0a8c891 100644 --- a/server/ui-src/templates/Message.vue +++ b/server/ui-src/templates/Message.vue @@ -167,21 +167,26 @@ export default { // Convert plain text to HTML including anchor links textToHTML: function (s) { - // escape to HTML let html = s + + // full links with http(s) + let re = /(\b(https?|ftp):\/\/[\-\w@:%_\+.~#?,&\/\/=;]+)\b/gim + html = html.replace(re, '˱˱˱a href=ˠˠˠ$&ˠˠˠ target=_blank rel=noopener˲˲˲$&˱˱˱/a˲˲˲') + + // plain www links without https?:// prefix + let re2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim + html = html.replace(re2, '$1˱˱˱a href=ˠˠˠhttp://$2ˠˠˠ target=ˠˠˠ_blankˠˠˠ rel=ˠˠˠnoopenerˠˠˠ˲˲˲$2˱˱˱/a˲˲˲') + + // escape to HTML & convert <>" back + html = html .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'") - - // full links with http(s) - let re = /(\b(https?|ftp):\/\/[\-\w@:%_\+.~#?,&\/\/=;]+)\b/gim - html = html.replace(re, '$&') - - // plain www links without https?:// prefix - let re2 = /(^|[^\/])(www\.[\S]+(\b|$))/gim - html = html.replace(re2, '$1$2') + .replace(/˱˱˱/g, '<') + .replace(/˲˲˲/g, '>') + .replace(/ˠˠˠ/g, '"') return html } @@ -326,7 +331,7 @@ export default { aria-labelledby="nav-html-tab" tabindex="0">
From 119b3864b2955bf800a3d2b882bd379a5d91e6a4 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Thu, 15 Jun 2023 22:25:47 +1200 Subject: [PATCH 2/2] Release v1.6.21 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1856f0..ff8610f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ Notable changes to Mailpit will be documented in this file. +## [v1.6.21] + +### UI +- More accurate clickable hyperlink logic in plain text messages + + ## [v1.6.20] ### Feature