@@ -1159,17 +1159,17 @@ def test_annotation_aggregate_with_m2o(self):
11591159 def test_alias_sql_injection (self ):
11601160 crafted_alias = """injected_name" from "annotations_book"; --"""
11611161 msg = (
1162- "Column aliases cannot contain whitespace characters, quotation marks, "
1163- "semicolons, or SQL comments."
1162+ "Column aliases cannot contain whitespace characters, hashes, quotation "
1163+ "marks, semicolons, or SQL comments."
11641164 )
11651165 with self .assertRaisesMessage (ValueError , msg ):
11661166 Book .objects .annotate (** {crafted_alias : Value (1 )})
11671167
11681168 def test_alias_filtered_relation_sql_injection (self ):
11691169 crafted_alias = """injected_name" from "annotations_book"; --"""
11701170 msg = (
1171- "Column aliases cannot contain whitespace characters, quotation marks, "
1172- "semicolons, or SQL comments."
1171+ "Column aliases cannot contain whitespace characters, hashes, quotation "
1172+ "marks, semicolons, or SQL comments."
11731173 )
11741174 with self .assertRaisesMessage (ValueError , msg ):
11751175 Book .objects .annotate (** {crafted_alias : FilteredRelation ("author" )})
@@ -1186,13 +1186,14 @@ def test_alias_forbidden_chars(self):
11861186 "ali/*as" ,
11871187 "alias*/" ,
11881188 "alias;" ,
1189- # [] are used by MSSQL.
1189+ # [] and # are used by MSSQL.
11901190 "alias[" ,
11911191 "alias]" ,
1192+ "ali#as" ,
11921193 ]
11931194 msg = (
1194- "Column aliases cannot contain whitespace characters, quotation marks, "
1195- "semicolons, or SQL comments."
1195+ "Column aliases cannot contain whitespace characters, hashes, quotation "
1196+ "marks, semicolons, or SQL comments."
11961197 )
11971198 for crafted_alias in tests :
11981199 with self .subTest (crafted_alias ):
@@ -1492,17 +1493,17 @@ def test_alias_after_values(self):
14921493 def test_alias_sql_injection (self ):
14931494 crafted_alias = """injected_name" from "annotations_book"; --"""
14941495 msg = (
1495- "Column aliases cannot contain whitespace characters, quotation marks, "
1496- "semicolons, or SQL comments."
1496+ "Column aliases cannot contain whitespace characters, hashes, quotation "
1497+ "marks, semicolons, or SQL comments."
14971498 )
14981499 with self .assertRaisesMessage (ValueError , msg ):
14991500 Book .objects .alias (** {crafted_alias : Value (1 )})
15001501
15011502 def test_alias_filtered_relation_sql_injection (self ):
15021503 crafted_alias = """injected_name" from "annotations_book"; --"""
15031504 msg = (
1504- "Column aliases cannot contain whitespace characters, quotation marks, "
1505- "semicolons, or SQL comments."
1505+ "Column aliases cannot contain whitespace characters, hashes, quotation "
1506+ "marks, semicolons, or SQL comments."
15061507 )
15071508 with self .assertRaisesMessage (ValueError , msg ):
15081509 Book .objects .alias (** {crafted_alias : FilteredRelation ("authors" )})
0 commit comments