Skip to content

Commit 8d4e96d

Browse files
qyanuKaiSchwarz-cnic
authored andcommitted
fix(apiclient): fixed empty ConvertIDN request
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.
1 parent 63477ea commit 8d4e96d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

hexonet/apiconnector/apiclient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,13 @@ def __autoIDNConvert(self, cmd):
419419
for key in cmd:
420420
if re.match(r'^(DOMAIN|NAMESERVER|DNSZONE)([0-9]*)$', key, re.IGNORECASE):
421421
keys.append(key)
422-
if not keys.count:
423-
return cmd
424422
idxs = []
425423
for key in keys:
426424
if not re.match(r'^[a-z0-9.-]+$', cmd[key], re.IGNORECASE):
427425
toconvert.append(cmd[key])
428426
idxs.append(key)
427+
if not toconvert:
428+
return cmd
429429

430430
r = self.request({
431431
"COMMAND": "ConvertIDN",

0 commit comments

Comments
 (0)