mirror of
https://github.com/Donkie/Spoolman.git
synced 2026-10-22 01:52:17 -05:00
Reject odd-length tag UIDs
This commit is contained in:
1 parent
7c4dcc7da7
commit
bce0d8069a
1 file changed
+2
@@ -82,6 +82,8 @@ def normalize_uid(uid: str) -> str:
|
||||
raise ValueError("A tag UID must not be empty.")
|
||||
if not _HEX_ONLY.match(normalized):
|
||||
raise ValueError(f'"{uid}" is not a valid tag UID. A UID must be hexadecimal.')
|
||||
if len(normalized) % 2:
|
||||
raise ValueError("A tag UID must contain a whole number of bytes (an even number of hex characters).")
|
||||
if len(normalized) > UID_MAX_LENGTH:
|
||||
raise ValueError(f"A tag UID can be at most {UID_MAX_LENGTH} hex characters.")
|
||||
return normalized
|
||||
|
||||
Reference in new issue
Block a user