mirror of https://gitlab.com/bashrc2/epicyon
Take out advertising trash when rendering html harmless
parent
1383c90462
commit
5ef53282ba
25
utils.py
25
utils.py
|
@ -5168,6 +5168,8 @@ def harmless_markup(post_json_object: {}) -> None:
|
||||||
if not isinstance(post_json_object['object'], dict):
|
if not isinstance(post_json_object['object'], dict):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
remove_trash = [' id="wordads-inline-marker"']
|
||||||
|
|
||||||
for field_name in ('content', 'summary'):
|
for field_name in ('content', 'summary'):
|
||||||
if post_json_object['object'].get(field_name):
|
if post_json_object['object'].get(field_name):
|
||||||
# tidy up content warnings
|
# tidy up content warnings
|
||||||
|
@ -5176,13 +5178,19 @@ def harmless_markup(post_json_object: {}) -> None:
|
||||||
post_json_object['object'][field_name] = \
|
post_json_object['object'][field_name] = \
|
||||||
valid_content_warning(summary)
|
valid_content_warning(summary)
|
||||||
|
|
||||||
if dangerous_markup(post_json_object['object'][field_name],
|
text = post_json_object['object'][field_name]
|
||||||
False, ['pre']):
|
|
||||||
|
# take out the trash
|
||||||
|
for trash in remove_trash:
|
||||||
|
if trash in text:
|
||||||
post_json_object['object'][field_name] = \
|
post_json_object['object'][field_name] = \
|
||||||
remove_html(post_json_object['object'][field_name])
|
text.replace(trash, '')
|
||||||
|
|
||||||
|
# remove things which would cause display issues
|
||||||
|
if dangerous_markup(text, False, ['pre']):
|
||||||
|
post_json_object['object'][field_name] = remove_html(text)
|
||||||
post_json_object['object'][field_name] = \
|
post_json_object['object'][field_name] = \
|
||||||
remove_markup_tag(post_json_object['object'][field_name],
|
remove_markup_tag(text, 'pre')
|
||||||
'pre')
|
|
||||||
|
|
||||||
map_name = field_name + 'Map'
|
map_name = field_name + 'Map'
|
||||||
if post_json_object['object'].get(map_name):
|
if post_json_object['object'].get(map_name):
|
||||||
|
@ -5198,6 +5206,13 @@ def harmless_markup(post_json_object: {}) -> None:
|
||||||
valid_content_warning(content)
|
valid_content_warning(content)
|
||||||
content = post_json_object['object'][map_name][lang]
|
content = post_json_object['object'][map_name][lang]
|
||||||
|
|
||||||
|
# take out the trash
|
||||||
|
for trash in remove_trash:
|
||||||
|
if trash in text:
|
||||||
|
post_json_object['object'][map_name][lang] = \
|
||||||
|
text.replace(trash, '')
|
||||||
|
|
||||||
|
# remove things which would cause display issues
|
||||||
if dangerous_markup(content, False, ['pre']):
|
if dangerous_markup(content, False, ['pre']):
|
||||||
content = remove_html(content)
|
content = remove_html(content)
|
||||||
post_json_object['object'][map_name][lang] = \
|
post_json_object['object'][map_name][lang] = \
|
||||||
|
|
Loading…
Reference in New Issue