forked from solderpunk/AV-98
offpunk: fix IPv6 as an URL (bug #40)
This commit is contained in:
parent
4a3ec61f1f
commit
d427287784
|
@ -1,5 +1,7 @@
|
|||
# Offpunk History
|
||||
|
||||
## 2.3 - Unreleased
|
||||
- offpunk: fix IPv6 as an URL (bug #40)
|
||||
|
||||
## 2.2 - February 13th 2023
|
||||
- cache folder is now configurable through $OFFPUNK_CACHE_PATH environment variable (by prx)
|
||||
|
|
13
offutils.py
13
offutils.py
|
@ -99,7 +99,7 @@ def fix_ipv6_url(url):
|
|||
netloc, rest = schemaless.split("/",1)
|
||||
if netloc.count(":") > 2 and "[" not in netloc and "]" not in netloc:
|
||||
schemaless = "[" + netloc + "]" + "/" + rest
|
||||
elif schemaless.count(":") > 2:
|
||||
elif schemaless.count(":") > 2 and "[" not in schemaless and "]" not in schemaless:
|
||||
schemaless = "[" + schemaless + "]/"
|
||||
if schema:
|
||||
return schema + "://" + schemaless
|
||||
|
@ -121,7 +121,16 @@ def looks_like_url(word):
|
|||
if mailto:
|
||||
return "@" in word
|
||||
elif not local:
|
||||
return start and ("." in word or "localhost" in word)
|
||||
if start:
|
||||
#IPv4
|
||||
if "." in word or "localhost" in word:
|
||||
return True
|
||||
#IPv6
|
||||
elif "[" in word and ":" in word and "]" in word:
|
||||
return True
|
||||
else: return False
|
||||
else: return False
|
||||
return start and ("." in word or "localhost" in word or ":" in word)
|
||||
else:
|
||||
return "/" in word
|
||||
except ValueError:
|
||||
|
|
Loading…
Reference in New Issue