]*>[\s\S]*?<\/a>)/g,m=>{_a_stash.push(m);return `\x00A${_a_stash.length-1}\x00`;});
- s=s.replace(/\[([^\]]+)\]\(((?:https?:\/\/|file:\/\/|workspace:\/\/|session:\/\/|mailto:|tel:)[^\s\)]+)\)/g,(_,label,url)=>_markdownAnchor(label,url));
+ s=s.replace(/\[([^\]]+)\]\(((?:https?:\/\/|file:\/\/|workspace:\/\/|session:\/\/|mailto:|tel:|message:)[^\s\)]+)\)/g,(_,label,url)=>_markdownAnchor(label,url));
s=s.replace(/\x00A(\d+)\x00/g,(_,i)=>_a_stash[+i]);
// Restore raw only after markdown rewrites so literal preformatted
// content stays placeholder-protected, then let the sanitizer normalize tags.
@@ -4919,7 +4919,7 @@ function renderMd(raw){
if(!compact) return false;
if(/^(javascript|data|vbscript):/i.test(compact)) return false;
if(/^https?:\/\//i.test(raw)) return true;
- if(/^(mailto:|tel:)/i.test(raw)) return true;
+ if(/^(mailto:|tel:|message:)/i.test(raw)) return true;
if(img && /^api\//i.test(raw)) return true;
if(!img && (/^api\//i.test(raw) || /^#/.test(raw) || _isInternalSessionHref(raw))) return true;
return false;
diff --git a/tests/test_issue2768_workspace_links.py b/tests/test_issue2768_workspace_links.py
index 0733e200..0d759d5b 100644
--- a/tests/test_issue2768_workspace_links.py
+++ b/tests/test_issue2768_workspace_links.py
@@ -63,10 +63,24 @@ def _render(markdown: str) -> str:
def test_workspace_markdown_renders_mailto_and_tel_links():
- html = _render("[email](mailto:foo@example.test) and [phone](tel:+15551212)")
+ html = _render("[email](mailto:foo@example.test) and [phone](tel:+155****1212)")
assert 'email' in html
- assert 'phone' in html
+ assert 'phone' in html
+
+
+def test_workspace_markdown_renders_message_scheme_links():
+ """macOS Mail `message:` links must render clickable (#4319) — same OS-handled
+ class as mailto:/tel: — while `javascript:` stays blocked even when a
+ `message:`-style label is attached."""
+ html = _render(
+ "[mail](message://%3Cabc@example.test%3E) "
+ "and [x](javascript:alert(1))"
+ )
+
+ assert 'mail' in html
+ # The javascript: scheme must NOT produce an executable href.
+ assert "javascript:alert(1)" not in html or 'href="javascript:' not in html
def test_workspace_html_iframe_allows_links_to_escape_sandbox():