Accept hostname targets that do not contain a period.

This fixes issue #123, which was due to a misinterpretation of the
line

`if host.split(".")[0][0].isalpha() or host.split(".")[-1][-1].isalpha():`

(see commit 8d46d14731, L156). Because of
how Python's str.split() works, a hostname that does not contain a
period when .split(".") results in a single-item list, so this
expression evaluates to True. However, this also means that the
.split()s had no effect: the line was equivalent to

`if host[0].isalpha() or host[-1].isalpha()`.
This commit is contained in:
Ira Lun
2020-10-12 04:56:54 +01:00
parent 9ba669da16
commit 7034a09e09

View File

@@ -187,10 +187,7 @@ class InputHelper(object):
for target_spec in target_specs: for target_spec in target_specs:
if ( if (
target_spec.startswith(".") or target_spec.startswith(".") or
( (target_spec[0].isalpha() or target_spec[-1].isalpha()) or
(target_spec[0].isalpha() or target_spec[-1].isalpha())
and "." in target_spec
) or
(nocidr and "/" in target_spec) (nocidr and "/" in target_spec)
): ):
str_targets.add(target_spec) str_targets.add(target_spec)