@@ -1161,12 +1161,12 @@ def test_alias_sql_injection(self):
11611161 crafted_alias = """injected_name" from "annotations_book"; --"""
11621162 # RemovedInDjango70Warning: When the deprecation ends, replace with:
11631163 # msg = (
1164- # "Column aliases cannot contain whitespace characters, quotation "
1165- # "marks, semicolons, percent signs, or SQL comments."
1164+ # "Column aliases cannot contain whitespace characters, hashes, "
1165+ # "quotation marks, semicolons, percent signs, or SQL comments."
11661166 # )
11671167 msg = (
1168- "Column aliases cannot contain whitespace characters, quotation marks, "
1169- "semicolons, or SQL comments."
1168+ "Column aliases cannot contain whitespace characters, hashes, quotation "
1169+ "marks, semicolons, or SQL comments."
11701170 )
11711171 with self .assertRaisesMessage (ValueError , msg ):
11721172 Book .objects .annotate (** {crafted_alias : Value (1 )})
@@ -1175,12 +1175,12 @@ def test_alias_filtered_relation_sql_injection(self):
11751175 crafted_alias = """injected_name" from "annotations_book"; --"""
11761176 # RemovedInDjango70Warning: When the deprecation ends, replace with:
11771177 # msg = (
1178- # "Column aliases cannot contain whitespace characters, quotation "
1179- # "marks, semicolons, percent signs, or SQL comments."
1178+ # "Column aliases cannot contain whitespace characters, hashes, "
1179+ # "quotation marks, semicolons, percent signs, or SQL comments."
11801180 # )
11811181 msg = (
1182- "Column aliases cannot contain whitespace characters, quotation marks, "
1183- "semicolons, or SQL comments."
1182+ "Column aliases cannot contain whitespace characters, hashes, quotation "
1183+ "marks, semicolons, or SQL comments."
11841184 )
11851185 with self .assertRaisesMessage (ValueError , msg ):
11861186 Book .objects .annotate (** {crafted_alias : FilteredRelation ("author" )})
@@ -1199,18 +1199,19 @@ def test_alias_forbidden_chars(self):
11991199 "alias;" ,
12001200 # RemovedInDjango70Warning: When the deprecation ends, add this:
12011201 # "alias%",
1202- # [] are used by MSSQL.
1202+ # [] and # are used by MSSQL.
12031203 "alias[" ,
12041204 "alias]" ,
1205+ "ali#as" ,
12051206 ]
12061207 # RemovedInDjango70Warning: When the deprecation ends, replace with:
12071208 # msg = (
1208- # "Column aliases cannot contain whitespace characters, quotation "
1209- # "marks, semicolons, percent signs, or SQL comments."
1209+ # "Column aliases cannot contain whitespace characters, hashes, "
1210+ # "quotation marks, semicolons, percent signs, or SQL comments."
12101211 # )
12111212 msg = (
1212- "Column aliases cannot contain whitespace characters, quotation marks, "
1213- "semicolons, or SQL comments."
1213+ "Column aliases cannot contain whitespace characters, hashes, quotation "
1214+ "marks, semicolons, or SQL comments."
12141215 )
12151216 for crafted_alias in tests :
12161217 with self .subTest (crafted_alias ):
@@ -1516,12 +1517,12 @@ def test_alias_sql_injection(self):
15161517 crafted_alias = """injected_name" from "annotations_book"; --"""
15171518 # RemovedInDjango70Warning: When the deprecation ends, replace with:
15181519 # msg = (
1519- # "Column aliases cannot contain whitespace characters, quotation "
1520- # "marks, semicolons, percent signs, or SQL comments."
1520+ # "Column aliases cannot contain whitespace characters, hashes, "
1521+ # "quotation marks, semicolons, percent signs, or SQL comments."
15211522 # )
15221523 msg = (
1523- "Column aliases cannot contain whitespace characters, quotation marks, "
1524- "semicolons, or SQL comments."
1524+ "Column aliases cannot contain whitespace characters, hashes, quotation "
1525+ "marks, semicolons, or SQL comments."
15251526 )
15261527 with self .assertRaisesMessage (ValueError , msg ):
15271528 Book .objects .alias (** {crafted_alias : Value (1 )})
@@ -1530,12 +1531,12 @@ def test_alias_filtered_relation_sql_injection(self):
15301531 crafted_alias = """injected_name" from "annotations_book"; --"""
15311532 # RemovedInDjango70Warning: When the deprecation ends, replace with:
15321533 # msg = (
1533- # "Column aliases cannot contain whitespace characters, quotation "
1534- # "marks, semicolons, percent signs, or SQL comments."
1534+ # "Column aliases cannot contain whitespace characters, hashes, "
1535+ # "quotation marks, semicolons, percent signs, or SQL comments."
15351536 # )
15361537 msg = (
1537- "Column aliases cannot contain whitespace characters, quotation marks, "
1538- "semicolons, or SQL comments."
1538+ "Column aliases cannot contain whitespace characters, hashes, quotation "
1539+ "marks, semicolons, or SQL comments."
15391540 )
15401541 with self .assertRaisesMessage (ValueError , msg ):
15411542 Book .objects .alias (** {crafted_alias : FilteredRelation ("authors" )})
0 commit comments