mirror of https://gitlab.com/bashrc2/epicyon
Improve handling of quotes within csv file
parent
8198daa3e5
commit
f9384492f7
17
blocking.py
17
blocking.py
|
@ -1530,11 +1530,22 @@ def import_blocks(base_dir: str, nickname: str, domain: str,
|
|||
# already blocked
|
||||
continue
|
||||
append_blocks.append(blocked_domain_name)
|
||||
blocked_comment = block_fields[comment_field_index].strip()
|
||||
if blocked_comment:
|
||||
if blocked_comment not in existing_reasons:
|
||||
blocked_comment = ''
|
||||
if '"' in line_str:
|
||||
quote_section = line_str.split('"')
|
||||
if len(quote_section) > 1:
|
||||
blocked_comment = quote_section[1]
|
||||
append_reasons.append(blocked_domain_name + ' ' +
|
||||
blocked_comment)
|
||||
if not blocked_comment:
|
||||
if len(block_fields) > comment_field_index:
|
||||
blocked_comment = block_fields[comment_field_index].strip()
|
||||
if blocked_comment:
|
||||
if blocked_comment.startswith('"'):
|
||||
blocked_comment = blocked_comment.replace('"', '')
|
||||
if blocked_comment not in existing_reasons:
|
||||
append_reasons.append(blocked_domain_name + ' ' +
|
||||
blocked_comment)
|
||||
if not append_blocks:
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in New Issue