Updated "mailto:" link URL
authorThierry Florac <tflorac@ulthar.net>
Tue, 22 Jan 2019 14:27:57 +0100
changeset 1248 2419d4bad22b
parent 1247 2b1abe98ff47
child 1249 0ffecffbd987
Updated "mailto:" link URL
src/pyams_content/component/links/__init__.py
--- a/src/pyams_content/component/links/__init__.py	Mon Jan 21 17:43:30 2019 +0100
+++ b/src/pyams_content/component/links/__init__.py	Tue Jan 22 14:27:57 2019 +0100
@@ -9,6 +9,8 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyramid.encode import url_quote
+
 
 __docformat__ = 'restructuredtext'
 
@@ -272,7 +274,10 @@
         return 'mailto:{0} <{1}>'.format(self.address_name, self.address)
 
     def get_url(self, request=None, view_name=None):
-        return 'mailto:{0} &lt;{1}&gt;'.format(self.address_name, self.address)
+        if self.address_name:
+            return 'mailto:{}'.format(url_quote('{} <{}>'.format(self.address_name, self.address)))
+        else:
+            return 'mailto:{}'.format(self.address)
 
 
 @adapter_config(context=IMailtoLink, provides=IAssociationInfo)