Use stdlib html.escape() in django.utils.html.escape()

Improves performance and removes duplicated code by leveraging Python's built-in html.escape(). Note: changes escaping of single quotes from ' to ', which may affect literal output.
This commit is contained in:
utkarsh.arya@zomato.com 2025-11-15 22:56:59 +00:00
parent 28d5262fa3
commit 7fcafcc265
14 changed files with 36 additions and 44 deletions

View file

@ -78,7 +78,7 @@ class UrlTagTests(SimpleTestCase):
@setup({'url12': '{% url "client_action" id=client.id action="!$&\'()*+,;=~:@," %}'})
def test_url12(self):
output = self.engine.render_to_string('url12', {'client': {'id': 1}})
self.assertEqual(output, '/client/1/!$&'()*+,;=~:@,/')
self.assertEqual(output, '/client/1/!$&'()*+,;=~:@,/')
@setup({'url13': '{% url "client_action" id=client.id action=arg|join:"-" %}'})
def test_url13(self):