Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

email_notifications: Run html2text as a subprocess.

Anders Kaseorge10b7f2f3c1c
diff --git a/zerver/lib/email_notifications.py b/zerver/lib/email_notifications.py
index 5fc6d186a72..38ff847dc65 100644
--- a/zerver/lib/email_notifications.py
+++ b/zerver/lib/email_notifications.py
@@ -2,12 +2,12 @@
import logging
import re
+import subprocess
from collections import defaultdict
from datetime import timedelta
from email.headerregistry import Address
from typing import Any, Dict, Iterable, List, Optional, Tuple
-import html2text
import lxml.html
import pytz
from bs4 import BeautifulSoup
@@ -704,8 +704,8 @@ def enqueue_welcome_emails(user: UserProfile, realm_creation: bool = False) -> N
def convert_html_to_markdown(html: str) -> str:
- parser = html2text.HTML2Text()
- markdown = parser.handle(html).strip()
+ # html2text is GPL licensed, so run it as a subprocess.
+ markdown = subprocess.check_output(["html2text"], input=html, text=True).strip()
# We want images to get linked and inline previewed, but html2text will turn
# them into links of the form `![](http://foo.com/image.png)`, which is