mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-05-09 05:21:13 +02:00
Fixed a problem where an html comment was detected as a valid tag, and crashed
the soup processing.
This commit is contained in:
parent
d89a5132ce
commit
4208f4ae6e
1 changed files with 4 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
def soup_up_div(body):
|
||||
blockTags = ['address', 'blockquote', 'del', 'div', 'dl', 'fieldset', 'form', 'ins', 'noscript', 'ol', 'p', 'pre', 'table', 'ul']
|
||||
|
|
@ -245,7 +245,7 @@ def soup_up_div(body):
|
|||
for i in soup.contents[0]:
|
||||
if str(i).strip().__len__() > 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*')
|
||||
|
|
|
|||
Loading…
Reference in a new issue