Skip to content

Commit

Permalink
fix(apiclient): fixed empty ConvertIDN request
Browse files Browse the repository at this point in the history
function __autoIDNConvert in class hexonet.apiconnector.apiclient.APIClient
would send an empty ConvertIDN request, if cmd contains at least one
key that matches r'^(DOMAIN|NAMESERVER|DNSZONE)([0-9]*)$', but all
values at such keys match r'^[a-z0-9.-]+$'

the result of an empty ConvertIDN request would never result in a change
of cmd and thus can be avoided.

this commit adds a check `if not toconvert` just before sending the
(empty) request in order to avoid it. for readability, the now redundant
check `if not key.count` is removed.
  • Loading branch information
qyanu authored and KaiSchwarz-cnic committed May 23, 2020
1 parent 63477ea commit 8d4e96d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hexonet/apiconnector/apiclient.py
Expand Up @@ -419,13 +419,13 @@ def __autoIDNConvert(self, cmd):
for key in cmd:
if re.match(r'^(DOMAIN|NAMESERVER|DNSZONE)([0-9]*)$', key, re.IGNORECASE):
keys.append(key)
if not keys.count:
return cmd
idxs = []
for key in keys:
if not re.match(r'^[a-z0-9.-]+$', cmd[key], re.IGNORECASE):
toconvert.append(cmd[key])
idxs.append(key)
if not toconvert:
return cmd

r = self.request({
"COMMAND": "ConvertIDN",
Expand Down

0 comments on commit 8d4e96d

Please sign in to comment.