mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-02 01:06:06 -04:00
Merge pull request from GHSA-22p3-qrh9-cx32
* Make _iterate_over_text easier to read by using simple data structures * Prefer a set of tags to ignore In my tests, it's 4x faster to check for containment in a set of this size * Add a stack size limit to _iterate_over_text * Continue accepting the case where there is no body element * Use an early return instead for None Co-authored-by: Richard van der Hoff <richard@matrix.org>
This commit is contained in:
parent
21e6c0ed64
commit
fa13080618
2 changed files with 56 additions and 24 deletions
|
@ -370,6 +370,23 @@ class OpenGraphFromHtmlTestCase(unittest.TestCase):
|
|||
og = parse_html_to_open_graph(tree)
|
||||
self.assertEqual(og, {"og:title": "ó", "og:description": "Some text."})
|
||||
|
||||
def test_nested_nodes(self) -> None:
|
||||
"""A body with some nested nodes. Tests that we iterate over children
|
||||
in the right order (and don't reverse the order of the text)."""
|
||||
html = b"""
|
||||
<a href="somewhere">Welcome <b>the bold <u>and underlined text <svg>
|
||||
with a cheeky SVG</svg></u> and <strong>some</strong> tail text</b></a>
|
||||
"""
|
||||
tree = decode_body(html, "http://example.com/test.html")
|
||||
og = parse_html_to_open_graph(tree)
|
||||
self.assertEqual(
|
||||
og,
|
||||
{
|
||||
"og:title": None,
|
||||
"og:description": "Welcome\n\nthe bold\n\nand underlined text\n\nand\n\nsome\n\ntail text",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
class MediaEncodingTestCase(unittest.TestCase):
|
||||
def test_meta_charset(self) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue