diff --git a/frappe/tests/test_utils.py b/frappe/tests/test_utils.py
index af13829e7e..948e26a74f 100644
--- a/frappe/tests/test_utils.py
+++ b/frappe/tests/test_utils.py
@@ -4,7 +4,7 @@ from __future__ import unicode_literals
import unittest
-from frappe.utils import evaluate_filters, money_in_words
+from frappe.utils import evaluate_filters, money_in_words, scrub_urls, get_url
class TestFilters(unittest.TestCase):
def test_simple_dict(self):
@@ -57,4 +57,30 @@ class TestMoney(unittest.TestCase):
self.assertEqual(
money_in_words(num[0], "NGN"), num[1], "{0} is not the same as {1}".
format(money_in_words(num[0], "NGN"), num[1])
- )
\ No newline at end of file
+ )
+
+class TestDataManipulation(unittest.TestCase):
+ def test_scrub_urls(self):
+ html = '''
+
You have a new message from: John
+ Hey, wassup!
+
+
+ Please mail us at
email
+
+ '''
+
+ html = scrub_urls(html)
+ url = get_url()
+
+ self.assertTrue('Test link 1' in html)
+ self.assertTrue('Test link 2'.format(url) in html)
+ self.assertTrue('Test link 3'.format(url) in html)
+ self.assertTrue('
'.format(url) in html)
+ self.assertTrue('style="background-image: url(\'{0}/assets/frappe/bg.jpg\') !important"'.format(url) in html)
+ self.assertTrue('email' in html)
diff --git a/frappe/utils/data.py b/frappe/utils/data.py
index 8408b4f5aa..8de7e3266f 100644
--- a/frappe/utils/data.py
+++ b/frappe/utils/data.py
@@ -778,9 +778,11 @@ def expand_relative_urls(html):
def _expand_relative_urls(match):
to_expand = list(match.groups())
- if not to_expand[2].startswith("/"):
- to_expand[2] = "/" + to_expand[2]
- to_expand.insert(2, url)
+
+ if not to_expand[2].startswith('mailto'):
+ if not to_expand[2].startswith("/"):
+ to_expand[2] = "/" + to_expand[2]
+ to_expand.insert(2, url)
if 'url' in to_expand[0] and to_expand[1].startswith('(') and to_expand[-1].endswith(')'):
# background-image: url('/assets/...') - workaround for wkhtmltopdf print-media-type