Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
markdown: Add support for sms and tel links.
Ganesh Pawar529f72fa3ffa
diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.pyindex d894068d3db..8baf0bc2aef 100644--- a/zerver/lib/markdown/__init__.py+++ b/zerver/lib/markdown/__init__.py@@ -1570,7 +1570,7 @@ def sanitize_url(url: str) -> Optional[str]:if not scheme:return sanitize_url("http://" + url)- locless_schemes = ["mailto", "news", "file", "bitcoin"]+ locless_schemes = ["mailto", "news", "file", "bitcoin", "sms", "tel"]if netloc == "" and scheme not in locless_schemes:# This fails regardless of anything else.# Return immediately to save additional processing@@ -1580,7 +1580,7 @@ def sanitize_url(url: str) -> Optional[str]:# appears to have a netloc. Additionally there are plenty of other# schemes that do weird things like launch external programs. To be# on the safe side, we whitelist the scheme.- if scheme not in ("http", "https", "ftp", "mailto", "file", "bitcoin"):+ if scheme not in ("http", "https", "ftp", "mailto", "file", "bitcoin", "sms", "tel"):return None# Upstream code scans path, parameters, and query for colon charactersdiff --git a/zerver/tests/fixtures/markdown_test_cases.json b/zerver/tests/fixtures/markdown_test_cases.jsonindex 7e1d67e894a..2c5819e3e60 100644--- a/zerver/tests/fixtures/markdown_test_cases.json+++ b/zerver/tests/fixtures/markdown_test_cases.json@@ -948,6 +948,11 @@"input": "<h1>*<h1>[<h2>Static types in Python</h2>](https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy)</h1>*</h1>","expected_output": "<p><h1><em><h1><a href=\"https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy\"><h2>Static types in Python</h2></a></h1></em></h1></p>","marked_expected_output": "<p><h1><em><h1><a href=\"https://blog.zulip.com/2016/10/13/static-types-in-python-oh-mypy\"><h2>Static types in Python</h2></a></h1></em></h1>\n\n</p>"+ },+ {+ "name": "telephone_sms_link",+ "input": "[call me](tel:+14155551234) [or maybe not](sms:+14155551234)",+ "expected_output": "<p><a href=\"tel:+14155551234\">call me</a> <a href=\"sms:+14155551234\">or maybe not</a></p>"}],"linkify_tests": [