|
5 | 5 | from django.utils.datastructures import MultiValueDict |
6 | 6 | from django.utils.deprecation import RemovedInDjango30Warning |
7 | 7 | from django.utils.http import ( |
8 | | - base36_to_int, cookie_date, http_date, int_to_base36, is_safe_url, |
9 | | - is_same_domain, parse_etags, parse_http_date, quote_etag, urlencode, |
10 | | - urlquote, urlquote_plus, urlsafe_base64_decode, urlsafe_base64_encode, |
11 | | - urlunquote, urlunquote_plus, |
| 8 | + base36_to_int, cookie_date, escape_leading_slashes, http_date, |
| 9 | + int_to_base36, is_safe_url, is_same_domain, parse_etags, parse_http_date, |
| 10 | + quote_etag, urlencode, urlquote, urlquote_plus, urlsafe_base64_decode, |
| 11 | + urlsafe_base64_encode, urlunquote, urlunquote_plus, |
12 | 12 | ) |
13 | 13 |
|
14 | 14 |
|
@@ -271,3 +271,14 @@ def test_parsing_rfc850(self): |
271 | 271 | def test_parsing_asctime(self): |
272 | 272 | parsed = parse_http_date('Sun Nov 6 08:49:37 1994') |
273 | 273 | self.assertEqual(datetime.utcfromtimestamp(parsed), datetime(1994, 11, 6, 8, 49, 37)) |
| 274 | + |
| 275 | + |
| 276 | +class EscapeLeadingSlashesTests(unittest.TestCase): |
| 277 | + def test(self): |
| 278 | + tests = ( |
| 279 | + ('//example.com', '/%2Fexample.com'), |
| 280 | + ('//', '/%2F'), |
| 281 | + ) |
| 282 | + for url, expected in tests: |
| 283 | + with self.subTest(url=url): |
| 284 | + self.assertEqual(escape_leading_slashes(url), expected) |
0 commit comments