diff --git a/notebook/files/handlers.py b/notebook/files/handlers.py index c54151125d..2c77c9d5e0 100644 --- a/notebook/files/handlers.py +++ b/notebook/files/handlers.py @@ -46,13 +46,15 @@ def get(self, path, include_body=True): self.set_header('Content-Type', 'application/x-ipynb+json') else: cur_mime = mimetypes.guess_type(name)[0] - if cur_mime is not None: + if cur_mime == 'text/plain': + self.set_header('Content-Type', 'text/plain; charset=UTF-8') + elif cur_mime is not None: self.set_header('Content-Type', cur_mime) else: if model['format'] == 'base64': self.set_header('Content-Type', 'application/octet-stream') else: - self.set_header('Content-Type', 'text/plain') + self.set_header('Content-Type', 'text/plain; charset=UTF-8') if include_body: if model['format'] == 'base64': diff --git a/notebook/tests/test_files.py b/notebook/tests/test_files.py index 9d0251482c..8345f3c467 100644 --- a/notebook/tests/test_files.py +++ b/notebook/tests/test_files.py @@ -95,7 +95,7 @@ def test_contents_manager(self): r = self.request('GET', 'files/test.txt') self.assertEqual(r.status_code, 200) - self.assertEqual(r.headers['content-type'], 'text/plain') + self.assertEqual(r.headers['content-type'], 'text/plain; charset=UTF-8') self.assertEqual(r.text, 'foobar') def test_download(self):