mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 17:55:26 -04:00
fix: uploaded files with no extension become permanently unresolvable (#1275)
* fix: accept extensionless upload ids so files like Dockerfile resolve * test: upload id validation accepts extensionless ids
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"""Tests for upload id validation (src/upload_handler.py)."""
|
||||
import uuid
|
||||
|
||||
from src.upload_handler import is_valid_upload_id
|
||||
|
||||
|
||||
def test_extensionless_id_is_valid():
|
||||
# save_upload builds `{uuid.hex}{ext}`; a file with no extension yields a
|
||||
# bare 32-hex id, which used to fail validation and become unresolvable.
|
||||
assert is_valid_upload_id(uuid.uuid4().hex) is True
|
||||
|
||||
|
||||
def test_id_with_extension_still_valid():
|
||||
assert is_valid_upload_id(uuid.uuid4().hex + ".png") is True
|
||||
|
||||
|
||||
def test_invalid_ids_rejected():
|
||||
assert is_valid_upload_id("not-an-id") is False
|
||||
assert is_valid_upload_id(uuid.uuid4().hex + ".") is False
|
||||
assert is_valid_upload_id("") is False
|
||||
assert is_valid_upload_id(uuid.uuid4().hex + ".tar.gz") is False
|
||||
Reference in New Issue
Block a user