Skip to content

Commit

Permalink
isup: don't assume .com any more if dot is missing
Browse files Browse the repository at this point in the history
The "com" TLD is nowhere near as common as it once was. It's probably
better to just inform the user that they forgot a dot, or tried to look
up a local (unqualified) name that Sopel won't be able to access.

Sopel definitely shouldn't just skip enforcing the presence of a dot,
since LAN names' existence shouldn't be accessible this way. Left a TODO
comment about mitigating this kind of risk.
  • Loading branch information
dgw committed Sep 18, 2020
1 parent e504eac commit 2863d72
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions sopel/modules/isup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_site_url(site):
or a :exc:`ValueError` is raised.
If the ``site`` does not have a scheme, ``http`` is used. If it doesn't
have a TLD, ``.com`` is used.
have a TLD, a :exc:`ValueError` is raised.
"""
site = site.strip() if site else ''
if not site:
Expand All @@ -41,7 +41,9 @@ def get_site_url(site):
site = 'http://' + site

if '.' not in site:
site += ".com"
# TODO: Make this more robust against e.g.
# .isup lanpeer/path/to/some/IoT.service
raise ValueError('I need a fully qualified domain name (with a dot).')

return site

Expand Down
3 changes: 1 addition & 2 deletions test/modules/test_modules_isup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@


VALID_SITE_URLS = (
# no TLD, no scheme
('example', 'http://example.com'),
# no scheme
('www.example.com', 'http://www.example.com'),
# with scheme
Expand Down Expand Up @@ -37,6 +35,7 @@ def test_get_site_url(site, expected):
' ', # empty once stripped
'steam://browsemedia', # invalid protocol
'://', # invalid protocol (that's a weird one)
'example', # no TLD, no scheme
)


Expand Down

0 comments on commit 2863d72

Please sign in to comment.