mirror of https://github.com/fail2ban/fail2ban
- Fixed UTF-8 log file reading
git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_6@247 a942ae1a-1317-0410-a47c-b1dcaea8d6050.6
parent
2304f07a38
commit
089770d1c0
|
@ -136,6 +136,11 @@ class LogReader:
|
||||||
self.setFilePos(logFile)
|
self.setFilePos(logFile)
|
||||||
lastLine = None
|
lastLine = None
|
||||||
for line in logFile:
|
for line in logFile:
|
||||||
|
try:
|
||||||
|
# Try to convert UTF-8 string to Latin-1
|
||||||
|
line = line.decode('utf-8').encode('latin-1')
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
pass
|
||||||
if not self.hasTime(line):
|
if not self.hasTime(line):
|
||||||
# There is no valid time in this line
|
# There is no valid time in this line
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue