~martijnbraam/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH numberstation] Gracefully handle doubles in URLs

Details
Message ID
<20221203214330.1674311-1-andrej.skvortzov@gmail.com>
DKIM signature
missing
Download raw message
Patch: +4 -4
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>
---
 numberstation/otpurl.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/numberstation/otpurl.py b/numberstation/otpurl.py
index f64f53f..628e3f0 100644
--- a/numberstation/otpurl.py
+++ b/numberstation/otpurl.py
@@ -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:
-- 
2.35.1

[PATCH numberstation] Use GtkSpinbox instead of GtkAdjustment to get integer value

Details
Message ID
<20221203214330.1674311-2-andrej.skvortzov@gmail.com>
In-Reply-To
<20221203214330.1674311-1-andrej.skvortzov@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Patch: +4 -4
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
---
 numberstation/window.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/numberstation/window.py b/numberstation/window.py
index bdcf2bd..59fc9e7 100644
--- a/numberstation/window.py
+++ b/numberstation/window.py
@@ -42,8 +42,8 @@ class NumberstationWindow:
        self.add_secret = builder.get_object("add_secret")
        self.add_totp = builder.get_object("add_totp")
        self.add_counter = builder.get_object("add_counter")
        self.add_length_adj = builder.get_object("add_length_adj")
        self.add_timer_adj = builder.get_object("add_timer_adj")
        self.add_length = builder.get_object("add_length")
        self.add_timer = builder.get_object("add_timer")
        self.add_save = builder.get_object("add_save")

        self.hamburgermenu = builder.get_object("hamburgermenu")
@@ -291,8 +291,8 @@ class NumberstationWindow:
        name = self.add_name.get_text().strip()
        type = 'totp' if self.add_totp.get_active() else 'hotp'
        secret = self.add_secret.get_text().strip()
        duration = self.add_timer_adj.get_value()
        length = self.add_length_adj.get_value()
        duration = self.add_timer.get_value_as_int()
        length = self.add_length.get_value_as_int()
        counter = self.add_counter.get_text().strip()
        if counter == '':
            counter = None
-- 
2.35.1

Re: [PATCH numberstation] Use GtkSpinbox instead of GtkAdjustment to get integer value

Details
Message ID
<Y8KE9Gkond/6GOga@skv.local>
In-Reply-To
<20221203214330.1674311-2-andrej.skvortzov@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Hi Martijn,

Do you have any feedback on these patches sent a month ago?
 - Use GtkSpinbox instead of GtkAdjustment to get integer value
 - Gracefully handle doubles in URLs

They fix usage of custom period for TOTP in numberstation, otherwise
it's not possible to add TOTP with custom period through UI or URL.
 
On 22-12-04 00:43, Andrey Skvortsov wrote:
> Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
> ---
>  numberstation/window.py | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/numberstation/window.py b/numberstation/window.py
> index bdcf2bd..59fc9e7 100644
> --- a/numberstation/window.py
> +++ b/numberstation/window.py
> @@ -42,8 +42,8 @@ class NumberstationWindow:
>          self.add_secret = builder.get_object("add_secret")
>          self.add_totp = builder.get_object("add_totp")
>          self.add_counter = builder.get_object("add_counter")
> -        self.add_length_adj = builder.get_object("add_length_adj")
> -        self.add_timer_adj = builder.get_object("add_timer_adj")
> +        self.add_length = builder.get_object("add_length")
> +        self.add_timer = builder.get_object("add_timer")
>          self.add_save = builder.get_object("add_save")
>  
>          self.hamburgermenu = builder.get_object("hamburgermenu")
> @@ -291,8 +291,8 @@ class NumberstationWindow:
>          name = self.add_name.get_text().strip()
>          type = 'totp' if self.add_totp.get_active() else 'hotp'
>          secret = self.add_secret.get_text().strip()
> -        duration = self.add_timer_adj.get_value()
> -        length = self.add_length_adj.get_value()
> +        duration = self.add_timer.get_value_as_int()
> +        length = self.add_length.get_value_as_int()
>          counter = self.add_counter.get_text().strip()
>          if counter == '':
>              counter = None
> -- 
> 2.35.1
> 

-- 
Best regards,
Andrey Skvortsov

Re: [PATCH numberstation] Use GtkSpinbox instead of GtkAdjustment to get integer value

Details
Message ID
<df2a7e27-e261-2f57-012e-cf4df9176957@brixit.nl>
In-Reply-To
<Y8KE9Gkond/6GOga@skv.local> (view parent)
DKIM signature
missing
Download raw message
Hi Andrey,

Sorry for the delay, I've applied your patches.
I had not encountered otp urls with decimals in them before, they don't 
really make sense for things like length but better to handle it than 
not I guess.

Greetings,
Martijn Braam

On 1/14/23 11:33, Andrey Skvortsov wrote:
> Hi Martijn,
>
> Do you have any feedback on these patches sent a month ago?
>   - Use GtkSpinbox instead of GtkAdjustment to get integer value
>   - Gracefully handle doubles in URLs
>
> They fix usage of custom period for TOTP in numberstation, otherwise
> it's not possible to add TOTP with custom period through UI or URL.
>   
> On 22-12-04 00:43, Andrey Skvortsov wrote:
>> Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
>> ---
>>   numberstation/window.py | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/numberstation/window.py b/numberstation/window.py
>> index bdcf2bd..59fc9e7 100644
>> --- a/numberstation/window.py
>> +++ b/numberstation/window.py
>> @@ -42,8 +42,8 @@ class NumberstationWindow:
>>           self.add_secret = builder.get_object("add_secret")
>>           self.add_totp = builder.get_object("add_totp")
>>           self.add_counter = builder.get_object("add_counter")
>> -        self.add_length_adj = builder.get_object("add_length_adj")
>> -        self.add_timer_adj = builder.get_object("add_timer_adj")
>> +        self.add_length = builder.get_object("add_length")
>> +        self.add_timer = builder.get_object("add_timer")
>>           self.add_save = builder.get_object("add_save")
>>   
>>           self.hamburgermenu = builder.get_object("hamburgermenu")
>> @@ -291,8 +291,8 @@ class NumberstationWindow:
>>           name = self.add_name.get_text().strip()
>>           type = 'totp' if self.add_totp.get_active() else 'hotp'
>>           secret = self.add_secret.get_text().strip()
>> -        duration = self.add_timer_adj.get_value()
>> -        length = self.add_length_adj.get_value()
>> +        duration = self.add_timer.get_value_as_int()
>> +        length = self.add_length.get_value_as_int()
>>           counter = self.add_counter.get_text().strip()
>>           if counter == '':
>>               counter = None
>> -- 
>> 2.35.1
>>
Reply to thread Export thread (mbox)