Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

i18n: Don't include email tags in translation strings.

Vishnu KSa888e65ea49d
diff --git a/templates/confirmation/confirm_email_change.html b/templates/confirmation/confirm_email_change.html
index ff77e4a5e26..79578da4461 100644
--- a/templates/confirmation/confirm_email_change.html
+++ b/templates/confirmation/confirm_email_change.html
@@ -11,7 +11,7 @@
<div class="app-main white-box">
{% trans %}
This confirms that the email address for your Zulip account has changed
- from <a href="mailto:{{old_email}}">{{old_email}}</a> to <a href="mailto:{{new_email}}">{{new_email}}</a>.
+ from {{ old_email_html_tag }} to {{ new_email_html_tag }}
{% endtrans %}
</div>
</div>
diff --git a/templates/confirmation/link_does_not_exist.html b/templates/confirmation/link_does_not_exist.html
index b7f481e3d55..eaca703024e 100644
--- a/templates/confirmation/link_does_not_exist.html
+++ b/templates/confirmation/link_does_not_exist.html
@@ -9,7 +9,7 @@
<h1 class="lead">{{ _("Whoops. We couldn't find your confirmation link in the system.") }}</h1>
<p>
{% trans %}
- Anyway, shoot us a line at <a href="mailto:{{ support_email }}">{{ support_email }}</a> and we'll get this resolved shortly.
+ Anyway, shoot us a line at {{ support_email_html_tag }} and we'll get this resolved shortly.
{% endtrans %}
</p>
</div>
diff --git a/templates/confirmation/link_malformed.html b/templates/confirmation/link_malformed.html
index 59f765b522e..070ded03a05 100644
--- a/templates/confirmation/link_malformed.html
+++ b/templates/confirmation/link_malformed.html
@@ -10,7 +10,7 @@
<p>{{ _("Make sure you copied the link correctly in to your browser. If you're still encountering this page, it's probably our fault. We're sorry.") }}</p>
<p>
{% trans %}
- Anyway, shoot us a line at <a href="mailto:{{ support_email }}">{{ support_email }}</a> and we'll get this resolved shortly.
+ Anyway, shoot us a line at {{ support_email_html_tag }} and we'll get this resolved shortly.
{% endtrans %}
</p>
</div>
diff --git a/zerver/context_processors.py b/zerver/context_processors.py
index 4c8f6db340e..17761742b7d 100644
--- a/zerver/context_processors.py
+++ b/zerver/context_processors.py
@@ -3,6 +3,8 @@ from urllib.parse import urljoin
from django.conf import settings
from django.http import HttpRequest
+from django.utils.html import escape
+from django.utils.safestring import SafeString
from version import (
LATEST_MAJOR_VERSION,
@@ -112,6 +114,9 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
settings_path = "/etc/zulip/settings.py"
settings_comments_path = "/etc/zulip/settings.py"
+ support_email = FromAddress.SUPPORT
+ support_email_html_tag = SafeString(f'<a href="mailto:{escape(support_email)}">{escape(support_email)}</a>')
+
# We can't use request.client here because we might not be using
# an auth decorator that sets it, but we can call its helper to
# get the same result.
@@ -136,7 +141,8 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
'apps_page_web': apps_page_web,
'open_realm_creation': settings.OPEN_REALM_CREATION,
'development_environment': settings.DEVELOPMENT,
- 'support_email': FromAddress.SUPPORT,
+ 'support_email': support_email,
+ 'support_email_html_tag': support_email_html_tag,
'find_team_link_disabled': find_team_link_disabled,
'password_min_length': settings.PASSWORD_MIN_LENGTH,
'password_min_guesses': settings.PASSWORD_MIN_GUESSES,
diff --git a/zerver/views/user_settings.py b/zerver/views/user_settings.py
index 01bf1facfca..ec3425b3b03 100644
--- a/zerver/views/user_settings.py
+++ b/zerver/views/user_settings.py
@@ -5,6 +5,8 @@ from django.contrib.auth import authenticate, update_session_auth_hash
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
+from django.utils.html import escape
+from django.utils.safestring import SafeString
from django.utils.translation import ugettext as _
from confirmation.models import (
@@ -69,8 +71,9 @@ def confirm_email_change(request: HttpRequest, confirmation_key: str) -> HttpRes
realm=user_profile.realm)
ctx = {
- 'new_email': new_email,
- 'old_email': old_email,
+ 'new_email_html_tag': SafeString(f'<a href="mailto:{escape(new_email)}">{escape(new_email)}</a>'),
+ 'old_email_html_tag': SafeString(f'<a href="mailto:{escape(old_email)}">{escape(old_email)}</a>'),
+
}
return render(request, 'confirmation/confirm_email_change.html', context=ctx)