Skip to content

Commit 7097c63

Browse files
committed
Fix isHostAndPort to reject leading zeros in port number
1 parent aef7b62 commit 7097c63

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

protovalidate/internal/extra_func.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,13 @@ def _is_hostname(val: str) -> bool:
225225
def _is_port(val: str) -> bool:
226226
if len(val) == 0:
227227
return False
228-
228+
if len(val) > 1 and val[0] == "0":
229+
return False
229230
for c in val:
230231
if c < "0" or c > "9":
231232
return False
232-
233233
try:
234234
return int(val) <= 65535
235-
236235
except ValueError:
237236
# Error converting to number
238237
return False

0 commit comments

Comments
 (0)