Skip to content

Commit

Permalink
Fix a logical bug.
Browse files Browse the repository at this point in the history
"not" has higher precedence over "and" operator. So, expression "not x and y" != "not x or not y".

The target is to check if any of the addr and port are invalid, but the current expression is true when addr is invalid but port is valid.
  • Loading branch information
Hedayet committed Dec 29, 2016
1 parent 63d0e31 commit 5c1898f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion web/net.py
Expand Up @@ -126,7 +126,7 @@ def validip(ip, defaultaddr="0.0.0.0", defaultport=8080):
raise ValueError(':'.join(ip) + ' is not a valid IP address/port')
elif len(ip) == 2:
addr, port = ip
if not validipaddr(addr) and validipport(port):
if not validipaddr(addr) or not validipport(port):
raise ValueError(':'.join(ip) + ' is not a valid IP address/port')
port = int(port)
else:
Expand Down

0 comments on commit 5c1898f

Please sign in to comment.