diff --git a/modules/networking.py b/modules/networking.py index bac15ba..e0c4eef 100644 --- a/modules/networking.py +++ b/modules/networking.py @@ -57,6 +57,10 @@ def traceURL(url, timeout=5, stack=None): stack = list() stack.append(url) + if len(stack) > 15: + stack.append('stack overflow :(') + return stack + o = urlparse(url, "http") if o.netloc == "": return stack @@ -72,12 +76,12 @@ def traceURL(url, timeout=5, stack=None): except socket.gaierror: print (" Unable to receive page %s from %s on %d." % (o.path, o.netloc, o.port)) - return None + return stack try: res = conn.getresponse() except http.client.BadStatusLine: - return None + return stack finally: conn.close() @@ -86,9 +90,9 @@ def traceURL(url, timeout=5, stack=None): elif res.status == http.client.FOUND or res.status == http.client.MOVED_PERMANENTLY or res.status == http.client.SEE_OTHER: url = res.getheader("Location") if url in stack: - stack.append(url) + stack.append("loop on " + url) return stack else: return traceURL(url, timeout, stack) else: - return None + return stack diff --git a/modules/ycc.py b/modules/ycc.py index 285a817..104d78a 100644 --- a/modules/ycc.py +++ b/modules/ycc.py @@ -56,12 +56,12 @@ def cmd_ycc(msg): def parselisten(msg): global LAST_URLS - res = re.match(".*([a-zA-Z0-9+.-]+):(//)?([^ ]*).*", msg.content) + res = re.match("([a-zA-Z0-9+.-]+:(//)?[^ ]*)", msg.content) if res is not None: url = res.group(1) o = urlparse(url) if o.scheme != "": - if o.netloc == "ycc.fr": + if o.netloc == "ycc.fr" or (o.netloc == "" and len(o.path) < 10): return False if msg.channel not in LAST_URLS: LAST_URLS[msg.channel] = list()