From 4208f4ae6e56d022f5ac4bef9863d0c0f572f910 Mon Sep 17 00:00:00 2001 From: asbjorn grandt Date: Sun, 10 Nov 2013 19:47:28 +0100 Subject: [PATCH] Fixed a problem where an html comment was detected as a valid tag, and crashed the soup processing. --- fanficdownloader/htmlheuristics.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fanficdownloader/htmlheuristics.py b/fanficdownloader/htmlheuristics.py index d4163859..54fef4d6 100644 --- a/fanficdownloader/htmlheuristics.py +++ b/fanficdownloader/htmlheuristics.py @@ -226,7 +226,7 @@ def replace_br_with_p(body): return body def is_valid_block(block): - return str(block).find('<') == 0 + return str(block).find('<') == 0 and str(block).find(' 0: s = str(i) - if is_valid_block(i): + if type(i) == bs.Tag: if i.name in blockTags: if lastElement > 1: body = body.strip(r'\s*(\[br\ \/\]\s*)*\s*') @@ -264,6 +264,8 @@ def soup_up_div(body): lastElement = 2 body += s + elif type(i) == bs.Comment: + body += s else: if lastElement == 1: body = body.strip(r'\s*(\[br\ \/\]\s*)*\s*')