aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg/validation.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 /webmentions_ssg/validation.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 '')
-rw-r--r--webmentions_ssg/validation.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/webmentions_ssg/validation.py b/webmentions_ssg/validation.py
new file mode 100644
index 0000000..e39d4d5
--- /dev/null
+++ b/webmentions_ssg/validation.py
@@ -0,0 +1,12 @@
+# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+"""Shared character validation helpers."""
+
+import unicodedata
+
+
+def is_control_character(character: str) -> bool:
+ """Identify Unicode control characters, including C0, DEL, and C1."""
+ return unicodedata.category(character) == "Cc"