summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorsri-vidyut <srividyut@hotmail.com>2021-07-28 02:29:42 +0900
committerGitHub <noreply@github.com>2021-07-27 17:29:42 +0000
commit8e1febc6a1e909eeb4334d5572956f669ee2d290 (patch)
treeebdf8521585d22567cf12dc1784bcf9288a39d6b /synapse
parentFix `oldest_pdu_in_federation_staging` (#10455) (diff)
downloadsynapse-8e1febc6a1e909eeb4334d5572956f669ee2d290.tar.xz
Support underscores (in addition to hyphens) for charset detection. (#10410)
Diffstat (limited to 'synapse')
-rw-r--r--synapse/rest/media/v1/preview_url_resource.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py
index 172212ee3a..0f051d4041 100644
--- a/synapse/rest/media/v1/preview_url_resource.py
+++ b/synapse/rest/media/v1/preview_url_resource.py
@@ -58,9 +58,11 @@ if TYPE_CHECKING:
 
 logger = logging.getLogger(__name__)
 
-_charset_match = re.compile(br'<\s*meta[^>]*charset\s*=\s*"?([a-z0-9-]+)"?', flags=re.I)
+_charset_match = re.compile(
+    br'<\s*meta[^>]*charset\s*=\s*"?([a-z0-9_-]+)"?', flags=re.I
+)
 _xml_encoding_match = re.compile(
-    br'\s*<\s*\?\s*xml[^>]*encoding="([a-z0-9-]+)"', flags=re.I
+    br'\s*<\s*\?\s*xml[^>]*encoding="([a-z0-9_-]+)"', flags=re.I
 )
 _content_type_match = re.compile(r'.*; *charset="?(.*?)"?(;|$)', flags=re.I)