aboutsummaryrefslogtreecommitdiff
path: root/tests/test_auth.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-13 08:39:18 +0100
committerDennis Fink2026-11-13 08:39:18 +0100
commit3496b3882ca08e74c108d5abe417eccec5ed4f48 (patch)
tree9b3b272e1b1162611feb8d33deb5eceb78efee88 /tests/test_auth.py
parenta227ec62b1cb0d5a4bb840072173607879e5d2f8 (diff)
downloadwebmentions-ssg-3496b3882ca08e74c108d5abe417eccec5ed4f48.tar.gz
webmentions-ssg-3496b3882ca08e74c108d5abe417eccec5ed4f48.zip
fix(core): reject all Unicode control characters
Use shared Unicode category validation so passwords reject C1 controls in addition to C0 and DEL, and reuse the same helper for URL validation.
Diffstat (limited to 'tests/test_auth.py')
-rw-r--r--tests/test_auth.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/test_auth.py b/tests/test_auth.py
index 008382a..c302e8f 100644
--- a/tests/test_auth.py
+++ b/tests/test_auth.py
@@ -8,10 +8,16 @@ import pytest
from flask import Flask
from webmentions_ssg import db
-from webmentions_ssg.auth import AUTH, is_safe_next_url, load_user
+from webmentions_ssg.auth import AUTH, is_safe_next_url, load_user, validate_password
from webmentions_ssg.models import User
+@pytest.mark.parametrize("character", ["\x00", "\x1f", "\x7f", "\x80", "\x9f"])
+def test_validate_password_rejects_unicode_controls(character: str) -> None:
+ with pytest.raises(ValueError, match="control characters"):
+ validate_password(f"valid passphrase{character}")
+
+
def test_user_loader_is_registered(app: Flask) -> None:
assert AUTH._user_callback is load_user