diff --git a/django/utils/encoding.py b/django/utils/encoding.py
index efc4ecc..b71ac27 100644
a
|
b
|
def filepath_to_uri(path):
|
234 | 234 | return path |
235 | 235 | # I know about `os.sep` and `os.altsep` but I want to leave |
236 | 236 | # some flexibility for hardcoding separators. |
237 | | return quote(force_bytes(path.replace("\\", "/")), safe=b"/~!*()'") |
| 237 | return quote(force_bytes(smart_text(path).replace("\\", "/")), safe=b"/~!*()'") |
238 | 238 | |
239 | 239 | def get_system_encoding(): |
240 | 240 | """ |
diff --git a/tests/text/tests.py b/tests/text/tests.py
index e61c14d..c85a5da 100644
a
|
b
|
|
2 | 2 | from __future__ import unicode_literals |
3 | 3 | |
4 | 4 | from django.test import TestCase |
5 | | from django.utils.encoding import iri_to_uri |
| 5 | from django.utils.encoding import iri_to_uri, filepath_to_uri |
6 | 6 | from django.utils.http import (cookie_date, http_date, |
7 | 7 | urlquote, urlquote_plus, urlunquote, urlunquote_plus) |
8 | 8 | from django.utils.text import get_text_list, smart_split |
… |
… |
class TextTests(TestCase):
|
103 | 103 | def test_iri_to_uri_idempotent(self): |
104 | 104 | self.assertEqual(iri_to_uri(iri_to_uri('red%09ros\xe9#red')), |
105 | 105 | 'red%09ros%C3%A9#red') |
| 106 | |
| 107 | def test_filepath_to_uri(self): |
| 108 | self.assertEqual(filepath_to_uri('upload\\чубака.mp4'), |
| 109 | 'upload/%D1%87%D1%83%D0%B1%D0%B0%D0%BA%D0%B0.mp4') |
| 110 | self.assertEqual(filepath_to_uri(b'upload\\чубака.mp4'), |
| 111 | b'upload/%D1%87%D1%83%D0%B1%D0%B0%D0%BA%D0%B0.mp4') |