From fa40f38c1b875e85782f06f4413a6f8e135fa3e5 Mon Sep 17 00:00:00 2001 From: John Garland Date: Mon, 9 Nov 2009 08:54:13 +0000 Subject: [PATCH] Allow for colons in PeerGuardian/SafePeer lists' descriptions. Check that the start & end range resembles an ip when checking a list's validity. --- ChangeLog | 1 + deluge/plugins/blocklist/blocklist/readers.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6b5ec1b71..3156d2c82 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,7 @@ ==== Blocklist ==== * Force blocklist to auto-detect format when a download / import is forced + * Fix blocklist failing on certain PeerGuardian/SafePeer lists === Deluge 1.2.0_rc3 (01 November 2009) === ==== Core ==== diff --git a/deluge/plugins/blocklist/blocklist/readers.py b/deluge/plugins/blocklist/blocklist/readers.py index 89ebd1559..a520fad3c 100644 --- a/deluge/plugins/blocklist/blocklist/readers.py +++ b/deluge/plugins/blocklist/blocklist/readers.py @@ -34,6 +34,7 @@ # from common import raiseError, remove_zeros +import re class ReaderParseError(Exception): pass @@ -69,6 +70,9 @@ class BaseReader(object): if not self.is_ignored(line): try: (start, end) = self.parse(line) + if not re.match("^(\d{1,3}\.){4}$", start + ".") or \ + not re.match("^(\d{1,3}\.){4}$", end + "."): + valid = False except: valid = False finally: @@ -94,7 +98,7 @@ class SafePeerReader(BaseReader): """Blocklist reader for SafePeer style blocklists""" @raiseError(ReaderParseError) def parse(self, line): - return line.strip().split(":")[1].split("-") + return line.strip().split(":")[-1].split("-") class PeerGuardianReader(SafePeerReader): """Blocklist reader for PeerGuardian style blocklists"""