Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 317248d

Browse files
authored
Improve URL previews by not including the content of media tags in the generated description. (#12887)
1 parent 9385cd0 commit 317248d

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

changelog.d/12887.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve URL previews by not including the content of media tags in the generated description.

synapse/rest/media/v1/preview_html.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,9 @@ def parse_html_description(tree: "etree.Element") -> Optional[str]:
246246
247247
Grabs any text nodes which are inside the <body/> tag, unless they are within
248248
an HTML5 semantic markup tag (<header/>, <nav/>, <aside/>, <footer/>), or
249-
if they are within a <script/> or <style/> tag.
249+
if they are within a <script/>, <svg/> or <style/> tag, or if they are within
250+
a tag whose content is usually only shown to old browsers
251+
(<iframe/>, <video/>, <canvas/>, <picture/>).
250252
251253
This is a very very very coarse approximation to a plain text render of the page.
252254
@@ -268,6 +270,12 @@ def parse_html_description(tree: "etree.Element") -> Optional[str]:
268270
"script",
269271
"noscript",
270272
"style",
273+
"svg",
274+
"iframe",
275+
"video",
276+
"canvas",
277+
"img",
278+
"picture",
271279
etree.Comment,
272280
)
273281

0 commit comments

Comments
 (0)