~martijnbraam/numberstation

6500431e317b8b5034929753c44f209a1029ce4b — Andrey Skvortsov 1 year, 9 months ago 441d1ca
Gracefully handle doubles in URLs

Otherwise following error happens:
```
  File "numberstation/window.py", line 302, in on_save_clicked
    url = OTPUrl.create(name=name, type=type, secret=secret, duration=duration, length=length, counter=counter)
  File "numberstation/otpurl.py", line 44, in create
    return cls(otp.provisioning_uri(name=name))
  File "numberstation/otpurl.py", line 26, in __init__
    self.period = int((qs['period'][0])) if 'period' in qs else 30
ValueError: invalid literal for int() with base 10: '60.0'
```

Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
1 files changed, 4 insertions(+), 4 deletions(-)

M numberstation/otpurl.py
M numberstation/otpurl.py => numberstation/otpurl.py +4 -4
@@ 23,11 23,11 @@ class OTPUrl:
        qs = parse_qs(parts.query)
        self.secret = qs['secret'][0]
        self.issuer = qs['issuer'][0] if 'issuer' in qs else None
        self.period = int(qs['period'][0]) if 'period' in qs else 30
        self.digits = int(qs['digits'][0]) if 'digits' in qs else 6
        self.initial_count = int(qs['counter'][0]) if 'counter' in qs else 0
        self.period = int(float(qs['period'][0])) if 'period' in qs else 30
        self.digits = int(float(qs['digits'][0])) if 'digits' in qs else 6
        self.initial_count = int(float(qs['counter'][0])) if 'counter' in qs else 0
        if 'initial_count' in qs:
            self.initial_count = int(qs['initial_count'][0])
            self.initial_count = int(float(qs['initial_count'][0]))

        self.digest = hashlib.sha1
        if 'digest' in qs: