Skip to content

Commit 62177a7

Browse files
author
Mavis Cron
committed
cleanup: remove duplicate _validate_port method in URLSanitizer
1 parent 1b0cb48 commit 62177a7

1 file changed

Lines changed: 0 additions & 15 deletions

File tree

security/url_sanitizer.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,6 @@ def _check_blocked_ip(self, ip, host):
140140
if not (self.allow_private and ip.is_private):
141141
raise InvalidURLError(f"Blocked IP address: {host}")
142142

143-
def _validate_port(self, port: Optional[int]) -> None:
144-
"""Validate port number against allowed/blocked lists."""
145-
if port is None:
146-
return
147-
if port < 1 or port > 65535:
148-
raise InvalidURLError(f"Invalid port number: {port}")
149-
if self.allowed_ports is not None:
150-
if port not in self.allowed_ports:
151-
raise InvalidURLError(
152-
f"Port {port} is not allowed. "
153-
f"Allowed ports: {', '.join(str(p) for p in self.allowed_ports)}"
154-
)
155-
elif port in self.BLOCKED_PORTS:
156-
raise InvalidURLError(f"Blocked port: {port}")
157-
158143
def _validate_port(self, port: Optional[int]) -> None:
159144
"""Validate port number against allowed/blocked lists."""
160145
if port is None:

0 commit comments

Comments
 (0)