fix: reject MAC address octets with a sign or whitespace (#424)
MacAddress.validate_mac_address parsed each octet with int(part, 16), which also accepts a leading +/- sign and surrounding whitespace. As a result strings like -a:-b:-c:-d:-e:-f, +a:+b:+c:+d:+e:+f and " a: b: c: d: e: f" were accepted, with the sign/whitespace variants silently normalized into a valid-looking MAC the caller never supplied. Require both characters of each octet to be hex digits before the int() conversion so malformed octets raise the mac_address_format error like other invalid input.
This commit is contained in:
1 parent
dfa8240f1f
commit
996db5006c
3 files changed
+14
-1
No files matched your search
@@ -2,6 +2,8 @@
|
||||
|
||||
## Latest Changes
|
||||
|
||||
* fix(mac_address): reject MAC octets with a sign or whitespace (e.g. `-a:...`, `+a:...`, ` a:...`) that `int(..., 16)` accepted.
|
||||
|
||||
## 2.11.2
|
||||
|
||||
* fix: accept common timezone abbreviations like EDT in TimeZoneName validator by @r266-tech in https://github.com/pydantic/pydantic-extra-types/pull/376
|
||||
|
||||
Reference in new issue
Block a user