mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
python: Avoid deprecated cgi module, removed in Python 3.13.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
006ac58a4b
commit
08db41660a
@@ -1,4 +1,4 @@
|
||||
import cgi
|
||||
from email.message import EmailMessage
|
||||
|
||||
from zerver.lib.url_preview.types import UrlEmbedData
|
||||
|
||||
@@ -10,9 +10,9 @@ class BaseParser:
|
||||
# importing it adds 10s of milliseconds to manage.py startup.
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
charset = None
|
||||
if content_type is not None:
|
||||
charset = cgi.parse_header(content_type)[1].get("charset")
|
||||
m = EmailMessage()
|
||||
m["Content-Type"] = content_type
|
||||
charset = m.get_content_charset()
|
||||
self._soup = BeautifulSoup(html_source, "lxml", from_encoding=charset)
|
||||
|
||||
def extract_data(self) -> UrlEmbedData:
|
||||
|
||||
Reference in New Issue
Block a user