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