@@ -1161,12 +1161,12 @@ def test_alias_sql_injection(self):
1161
1161
crafted_alias = """injected_name" from "annotations_book"; --"""
1162
1162
# RemovedInDjango70Warning: When the deprecation ends, replace with:
1163
1163
# 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."
1166
1166
# )
1167
1167
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."
1170
1170
)
1171
1171
with self .assertRaisesMessage (ValueError , msg ):
1172
1172
Book .objects .annotate (** {crafted_alias : Value (1 )})
@@ -1175,12 +1175,12 @@ def test_alias_filtered_relation_sql_injection(self):
1175
1175
crafted_alias = """injected_name" from "annotations_book"; --"""
1176
1176
# RemovedInDjango70Warning: When the deprecation ends, replace with:
1177
1177
# 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."
1180
1180
# )
1181
1181
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."
1184
1184
)
1185
1185
with self .assertRaisesMessage (ValueError , msg ):
1186
1186
Book .objects .annotate (** {crafted_alias : FilteredRelation ("author" )})
@@ -1199,18 +1199,19 @@ def test_alias_forbidden_chars(self):
1199
1199
"alias;" ,
1200
1200
# RemovedInDjango70Warning: When the deprecation ends, add this:
1201
1201
# "alias%",
1202
- # [] are used by MSSQL.
1202
+ # [] and # are used by MSSQL.
1203
1203
"alias[" ,
1204
1204
"alias]" ,
1205
+ "ali#as" ,
1205
1206
]
1206
1207
# RemovedInDjango70Warning: When the deprecation ends, replace with:
1207
1208
# 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."
1210
1211
# )
1211
1212
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."
1214
1215
)
1215
1216
for crafted_alias in tests :
1216
1217
with self .subTest (crafted_alias ):
@@ -1516,12 +1517,12 @@ def test_alias_sql_injection(self):
1516
1517
crafted_alias = """injected_name" from "annotations_book"; --"""
1517
1518
# RemovedInDjango70Warning: When the deprecation ends, replace with:
1518
1519
# 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."
1521
1522
# )
1522
1523
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."
1525
1526
)
1526
1527
with self .assertRaisesMessage (ValueError , msg ):
1527
1528
Book .objects .alias (** {crafted_alias : Value (1 )})
@@ -1530,12 +1531,12 @@ def test_alias_filtered_relation_sql_injection(self):
1530
1531
crafted_alias = """injected_name" from "annotations_book"; --"""
1531
1532
# RemovedInDjango70Warning: When the deprecation ends, replace with:
1532
1533
# 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."
1535
1536
# )
1536
1537
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."
1539
1540
)
1540
1541
with self .assertRaisesMessage (ValueError , msg ):
1541
1542
Book .objects .alias (** {crafted_alias : FilteredRelation ("authors" )})
0 commit comments