mirror of https://gitlab.com/bashrc2/epicyon
Fix for cwlists on domains which begin with a dot
parent
d03b04beda
commit
19f568dd06
|
|
@ -81,10 +81,12 @@ def _add_cw_match_domains(item: {}, content: str, cw_text: str,
|
||||||
the post content
|
the post content
|
||||||
"""
|
"""
|
||||||
matched = False
|
matched = False
|
||||||
|
|
||||||
for domain in item['domains']:
|
for domain in item['domains']:
|
||||||
if '.' in domain:
|
if '.' in domain:
|
||||||
first_section = domain.split('.')[0]
|
first_section = domain.split('.')[0]
|
||||||
if len(first_section) < 4:
|
len_first_section = len(first_section)
|
||||||
|
if len_first_section in range(1, 4):
|
||||||
if '.' + domain in content or \
|
if '.' + domain in content or \
|
||||||
'/' + domain in content:
|
'/' + domain in content:
|
||||||
if cw_text:
|
if cw_text:
|
||||||
|
|
@ -116,6 +118,7 @@ def add_cw_from_lists(post_json_object: {}, cw_lists: {}, translate: {},
|
||||||
if 'content' not in post_json_object['object']:
|
if 'content' not in post_json_object['object']:
|
||||||
if 'contentMap' not in post_json_object['object']:
|
if 'contentMap' not in post_json_object['object']:
|
||||||
return
|
return
|
||||||
|
|
||||||
cw_text: str = ''
|
cw_text: str = ''
|
||||||
if post_json_object['object'].get('summary'):
|
if post_json_object['object'].get('summary'):
|
||||||
cw_text = post_json_object['object']['summary']
|
cw_text = post_json_object['object']['summary']
|
||||||
|
|
|
||||||
|
|
@ -3324,6 +3324,6 @@
|
||||||
"www.ipv6.rs",
|
"www.ipv6.rs",
|
||||||
"www.homediningkitchen.com",
|
"www.homediningkitchen.com",
|
||||||
"www.psichologyanswers.com",
|
"www.psichologyanswers.com",
|
||||||
"www.umatechnology.org",
|
"www.umatechnology.org"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
tests.py
20
tests.py
|
|
@ -7628,6 +7628,26 @@ def _test_add_cw_lists(base_dir: str) -> None:
|
||||||
assert post_json_object['object']['summary'] == \
|
assert post_json_object['object']['summary'] == \
|
||||||
"Murdoch Press / Existing CW"
|
"Murdoch Press / Existing CW"
|
||||||
|
|
||||||
|
content = \
|
||||||
|
'<p>Wah wah-wah wah waaaah.</p><p><a ' + \
|
||||||
|
'href="https://www.ft.com/content/abcdef" target="_blank" ' + \
|
||||||
|
'rel="nofollow noopener" translate="no"><span class="invisible">' + \
|
||||||
|
'https://www.</span><span class="ellipsis">ft.com/content/abcdef' + \
|
||||||
|
'</span><span class="invisible">ghi</span></a></p>'
|
||||||
|
post_json_object = {
|
||||||
|
"object": {
|
||||||
|
"sensitive": True,
|
||||||
|
"summary": "Existing CW",
|
||||||
|
"content": content
|
||||||
|
}
|
||||||
|
}
|
||||||
|
add_cw_from_lists(post_json_object, cw_lists, translate,
|
||||||
|
'Paywalled or registration only',
|
||||||
|
system_language, languages_understood)
|
||||||
|
assert post_json_object['object']['sensitive'] is True
|
||||||
|
assert post_json_object['object']['summary'] == \
|
||||||
|
"Paywalled or Registration Only / Existing CW"
|
||||||
|
|
||||||
|
|
||||||
def _test_valid_emoji_content() -> None:
|
def _test_valid_emoji_content() -> None:
|
||||||
print('test_valid_emoji_content')
|
print('test_valid_emoji_content')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue