From 3496b3882ca08e74c108d5abe417eccec5ed4f48 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Fri, 13 Nov 2026 08:39:18 +0100 Subject: 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. --- tests/test_auth.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests/test_auth.py') 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 -- cgit v1.3.1