[issue36757] uuid constructor accept invalid strings (extra dash)

2019-05-01 Thread Cédric Cabessa

Cédric Cabessa  added the comment:

> Is there are reason your validator doesn't use uuid.UUID to normalize the 
> value? That is, whatever the customer provides, why not use the result of 
> stringifying the resulting UUID

Yes, this is exactly what we do now

However this behaviour is a bit surprising, we were thinking that uuid.UUID 
could be used as a validator

I understand the risk of breaking existing code with a fix that enforce a 
strict form.

Maybe a line should be added in the documentation to prevent people using this 
as a validator without more check?

But ok, you can close the bug if you prefer ... I think there no perfect 
solution :-)

--

___
Python tracker 
<https://bugs.python.org/issue36757>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36757] uuid constructor accept invalid strings (extra dash)

2019-04-30 Thread Cédric Cabessa

New submission from Cédric Cabessa :

UUID constructor accept string with too many dashes or keyword like urn: / uuid:

For eg, this code do not raise

```
>>> import uuid
>>> uuid.UUID('0be--468urn:urn:urn:urn:54-4bf9-41--d4-9697-41d735uuid:4fbe85uuid:')
UUID('0be46854-4bf9-41d4-9697-41d7354fbe85')
```

For the context, we use a validator based on `uuid.UUID` for an API.
Some customer send string with a UUID followed by extra `-`, the validator let 
it pass but the sql connector raise an exception

We workaround this in our validator, but UUID constructor should not accept 
string like the one in exemple

--
components: Library (Lib)
messages: 341141
nosy: Cédric Cabessa
priority: normal
severity: normal
status: open
title: uuid constructor accept invalid strings (extra dash)
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue36757>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com