From 0facbe04ef8bad6dce35cca89ea1dbe206bbd7d1 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Sun, 5 May 2013 13:31:06 -0500 Subject: [PATCH] support for different representations of IPv4 in IPv6, thanks Jonathan --- VERSION | 2 +- gluon/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 16e759a9..1680411a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.6-stable+timestamp.2013.05.05.10.12.31 +Version 2.4.6-stable+timestamp.2013.05.05.13.30.20 diff --git a/gluon/utils.py b/gluon/utils.py index 733c6f3a..8a0ac07c 100644 --- a/gluon/utils.py +++ b/gluon/utils.py @@ -305,8 +305,8 @@ def is_loopback_ip_address(ip=None, addrinfo=None): ip = addrinfo[4] if not isinstance(ip, basestring): return False - if ip.count('.') == 3: # IPv4 - return ip.startswith('127') or ip.startswith('::127') or ip.startswith(' 0:0:0:0:0:0:127') + if ip.count('.') == 3: # IPv4 or IPv6-embedded IPv4 or IPv4-compatible IPv6 + return ip.lower().startswith(('127', '::127', '0:0:0:0:0:0:127', '::ffff:127', '0:0:0:0:0:ffff:127')) return ip == '::1' or ip == '0:0:0:0:0:0:0:1' # IPv6 loopback