Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
fix: fail fast if attempting to validate empty hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Jan 5, 2024
1 parent fd7557d commit 66b200b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions httpobs/website/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ def api_post_scan_hostname():
# TODO: Allow people to accidentally use https://mozilla.org and convert to mozilla.org

# Get the hostname
hostname = request.args.get('host', '').lower()
hostname = request.args.get('host', '').lower().strip()

# Fail if it's not a valid hostname (not in DNS, not a real hostname, etc.)
ip = True if valid_hostname(hostname) is None else False
hostname = valid_hostname(hostname) or valid_hostname('www.' + hostname) # prepend www. if necessary
hostname = valid_hostname(hostname) or (
valid_hostname('www.' + hostname) if hostname else False
) # prepend www. if necessary

if ip:
return {
Expand Down

0 comments on commit 66b200b

Please sign in to comment.