Skip to content

Commit add4124

Browse files
committed
Fix #44: Fix an edge case while merging tags
1 parent 4cef99a commit add4124

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

html_sanitizer/sanitizer.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,9 @@ def sanitize(self, html):
372372
nx.text,
373373
)
374374
else:
375-
element.text = "{}{}".format(element.text or "", nx.text)
375+
element.text = "{}{}{}".format(
376+
element.text or "", element.tail or "", nx.text
377+
)
376378

377379
for child in nx:
378380
element.append(child)

html_sanitizer/tests.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest import TestCase, expectedFailure
1+
from unittest import TestCase
22

33
from .sanitizer import Sanitizer
44

@@ -666,7 +666,6 @@ def test_normalize_early(self):
666666
]
667667
)
668668

669-
@expectedFailure
670669
def test_typographic_whitespace_tags_merging(self):
671670
html = "This is <strong>some</strong> <strong>text</strong> with adjacent tags."
672671
sanitizer = Sanitizer(
@@ -677,7 +676,7 @@ def test_typographic_whitespace_tags_merging(self):
677676
)
678677
self.run_tests(
679678
[
680-
(html, "This is <strong>some text</strong> with adjacent tags."),
679+
(html, "This is <strong>some text</strong> with adjacent tags."),
681680
],
682681
sanitizer=sanitizer,
683682
)

0 commit comments

Comments
 (0)