fix: prevent url's from appearing as links in mail clients

code_spécifique_watcha watcha-20220615T155606-8744bec
c-cal 2 years ago
parent f3e73063c6
commit 8744becc7c
Signed by: watcha
GPG Key ID: 87DD78E7F7A1581D
  1. 12
      synapse/push/mailer.py
  2. 4
      synapse/res/templates/watcha_registration.html

@ -45,6 +45,7 @@ if TYPE_CHECKING:
from synapse.server import HomeServer
# watcha+
import re
from base64 import b64encode
from pathlib import Path
@ -136,6 +137,9 @@ class Mailer:
logger.info("Created Mailer for app_name %s" % app_name)
# watcha+
def _disguise_html_link(self, link: str) -> str:
return re.sub("[.@]", "<span>\g<0></span>", link)
def _get_b64_image(self, image_name):
b64_image_cache = self.__dict__.setdefault("_watcha_image_cache", {})
b64_image = b64_image_cache.get(image_name)
@ -183,7 +187,9 @@ class Mailer:
sender_name = await self.profile_handler.get_displayname(
UserID.from_string(sender_id)
)
sender_addresses = await self.account_handler._get_email_addresses_for_user(sender_id)
sender_addresses = await self.account_handler._get_email_addresses_for_user(
sender_id
)
if sender_name and sender_addresses:
sender_name += f" ({sender_addresses[0]})"
@ -211,9 +217,9 @@ class Mailer:
template_vars = {
"title": subject,
"sender_name": sender_name,
"identifier": email_address,
"identifier": self._disguise_html_link(email_address),
"password": password,
"workspace": workspace,
"workspace": self._disguise_html_link(workspace),
"login_url": login_url,
"is_partner": (
is_partner

@ -32,7 +32,7 @@
</td>
</tr>
<tr>
<td style="padding-left: 2em">{{ identifier }}</td>
<td style="padding-left: 2em">{{ identifier | safe }}</td>
</tr>
<tr>
<td>
@ -48,7 +48,7 @@
</td>
</tr>
<tr>
<td style="padding-left: 2em">{{ workspace }}</td>
<td style="padding-left: 2em">{{ workspace | safe }}</td>
</tr>
</tbody>
</table>

Loading…
Cancel
Save