8000 Insert text inside iframe for correct output · Harry0201/python-readability@d04d41b · GitHub
[go: up one dir, main page]

Skip to content

Commit d04d41b

Browse files
Miguel Galvesburiy
authored andcommitted
Insert text inside iframe for correct output
1 parent be2a1c4 commit d04d41b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

readability/readability.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def summary(self, html_partial=False):
183183
if article is None:
184184
article = self.html
185185
cleaned_article = self.sanitize(article, candidates)
186+
186187
article_length = len(cleaned_article or '')
187188
retry_length = self.options.get(
188189
'retry_length',
@@ -432,7 +433,9 @@ def sanitize(self, node, candidates):
432433
elem.drop_tree()
433434

434435
for elem in self.tags(node, "iframe"):
435-
if not ("src" in elem.attrib and REGEXES["videoRe"].search(elem.attrib["src"])):
436+
if "src" in elem.attrib and REGEXES["videoRe"].search(elem.attrib["src"]):
437+
elem.text = "VIDEO" # ADD content to iframe text node to force <iframe></iframe> proper output
438+
else:
436439
elem.drop_tree()
437440

438441
allowed = {}

0 commit comments

Comments
 (0)
0