From 2a5b7e2aa361e2fae466b7a60861a2a77d6ba1f8 Mon Sep 17 00:00:00 2001 From: Michal Proszek Date: Mon, 10 Jul 2017 19:44:55 +0200 Subject: [PATCH] APD-363 - [BE] do not replace tel: links with base_url (#1) (#183) * APD-363 - [BE] do not replace tel: links with base_url * Correct typo * Correct test html * Correct description grammar --- premailer/premailer.py | 2 ++ premailer/tests/test_premailer.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/premailer/premailer.py b/premailer/premailer.py index fc157ee..7cfb186 100644 --- a/premailer/premailer.py +++ b/premailer/premailer.py @@ -485,6 +485,8 @@ class Premailer(object): url.startswith('cid:') ): continue + if attr == 'href' and url.startswith('tel:'): + continue parent.attrib[attr] = urljoin(self.base_url, url) if hasattr(self.html, "getroottree"): diff --git a/premailer/tests/test_premailer.py b/premailer/tests/test_premailer.py index 5cdf6a7..dc7f2c1 100644 --- a/premailer/tests/test_premailer.py +++ b/premailer/tests/test_premailer.py @@ -837,6 +837,25 @@ ical-align:middle" bgcolor="red" valign="middle">Cell 2 compare_html(expect_html, result_html) + def test_tel_url(self): + """if you use URL with tel: protocol, it should stay as tel: + when baseurl is used + """ + + html = """ + + Title + + + 202-555-0113 + + """ + + p = Premailer(html, base_url='http://kungfupeople.com') + result_html = p.transform() + + compare_html(result_html, html) + def test_uppercase_margin(self): """Option to comply with outlook.com