@@ -165,11 +165,25 @@ def validate_input_xss_safety(value: str) -> str:
165165 strip_whitespace = True ,
166166 min_length = 1 ,
167167 max_length = MAX_NAME_LENGTH ,
168- pattern = r"^[A-Za-z0-9 ._-]+$" , # string that ONLY contains alphanumeric characters, spaces, dots, underscores, or hyphens
168+ pattern = r"^[A-Za-z0-9 ._-]+$" ,
169+ # CAREFUL: string that ONLY contains alphanumeric characters, spaces, dots, underscores, or hyphens
169170 ),
170171 AfterValidator (validate_input_xss_safety ),
172+ annotated_types .doc (
173+ """ A safe string used in **name identifiers**, It might be very restrictive for display names (e.g. titles or labels) """
174+ ),
171175]
172176
177+ DisplaySafeStr : TypeAlias = Annotated [
178+ str ,
179+ StringConstraints (
180+ strip_whitespace = True ,
181+ min_length = 1 ,
182+ max_length = MAX_NAME_LENGTH ,
183+ ),
184+ AfterValidator (validate_input_xss_safety ),
185+ annotated_types .doc (""" Like `NameSafeStr` but more suited for display names""" ),
186+ ]
173187
174188DescriptionSafeStr : TypeAlias = Annotated [
175189 str ,
@@ -200,7 +214,7 @@ def validate_input_xss_safety(value: str) -> str:
200214 strip_whitespace = True ,
201215 min_length = 1 ,
202216 max_length = 200 ,
203- pattern = r"^[A-Za-z0-9 ._-]*$" , # Allow alphanumeric, spaces, dots, underscores, hyphens, and asterisks
217+ pattern = r"^[A-Za-z0-9 ._@ -]*$" , # Allow alphanumeric, spaces, dots, underscores, hyphens, and at signs
204218 ),
205219 AfterValidator (validate_input_xss_safety ),
206220 annotated_types .doc (
0 commit comments