diff --git a/flask/helpers.py b/flask/helpers.py index cfc2d408..28771a98 100644 --- a/flask/helpers.py +++ b/flask/helpers.py @@ -959,7 +959,15 @@ def total_seconds(td): """ return td.days * 60 * 60 * 24 + td.seconds -def is_IP(string): +def is_IP(string, var_name): + """Returns the if the string received is an IP or not. + + :param string: the string to check if it an IP or not + :param var_name: the name of the variable that is being checked + + :returns: True if string is an IP, False if not + :rtype: boolean + """ ipv4 = string.split('.') ipv6 = string.split(':') try: @@ -967,7 +975,7 @@ def is_IP(string): if not t: ipv6[i] = "0" if(all(int(t,16) >= 0 and int(t,16) <= 65535 for t in ipv6)): - print("IPv6 address introduced in SESSION_COOKIE_DOMAIN!") + print("IPv6 address introduced in " + var_name) return True except ValueError: pass @@ -975,7 +983,7 @@ def is_IP(string): if len(ipv4) == 4: try: if(all(int(t) >= 0 and int(t) <= 255 for t in ipv4)): - print("IPv4 address introduced in SESSION_COOKIE_DOMAIN!") + print("IPv4 address introduced in " + var_name) except ValueError: return False else: diff --git a/flask/sessions.py b/flask/sessions.py index 86283f25..c7468832 100644 --- a/flask/sessions.py +++ b/flask/sessions.py @@ -332,7 +332,7 @@ class SecureCookieSessionInterface(SessionInterface): def save_session(self, app, session, response): domain = self.get_cookie_domain(app) - is_IP(domain) + is_IP(domain, "SESSION_COOKIE_DOMAIN") path = self.get_cookie_path(app) # Delete case. If there is no session we bail early.