[#3127|Blocklist] Fix importing blocklist with encoded lines
There are some blocklists with encoded names that break upon importing so decode lines to unicode. Need to use decode_bytes as not all encoded lines are utf8!
This commit is contained in:
parent
9bcda41700
commit
95d826b77c
|
@ -12,6 +12,7 @@ from __future__ import unicode_literals
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
from deluge.common import decode_bytes
|
||||||
from .common import IP, BadIP, raises_errors_as
|
from .common import IP, BadIP, raises_errors_as
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -54,6 +55,7 @@ class BaseReader(object):
|
||||||
blocklist = self.open()
|
blocklist = self.open()
|
||||||
valid = True
|
valid = True
|
||||||
for line in blocklist:
|
for line in blocklist:
|
||||||
|
line = decode_bytes(line)
|
||||||
if not self.is_ignored(line):
|
if not self.is_ignored(line):
|
||||||
try:
|
try:
|
||||||
(start, end) = self.parse(line)
|
(start, end) = self.parse(line)
|
||||||
|
@ -71,6 +73,7 @@ class BaseReader(object):
|
||||||
"""Yields each ip range from the file"""
|
"""Yields each ip range from the file"""
|
||||||
blocklist = self.open()
|
blocklist = self.open()
|
||||||
for line in blocklist:
|
for line in blocklist:
|
||||||
|
line = decode_bytes(line)
|
||||||
if not self.is_ignored(line):
|
if not self.is_ignored(line):
|
||||||
yield self.parse(line)
|
yield self.parse(line)
|
||||||
blocklist.close()
|
blocklist.close()
|
||||||
|
|
Loading…
Reference in New Issue