Skip to content

Commit 3ae5d5e

Browse files
committedAug 23, 2015
Set UTF-8 charset in Content-Type in the auto command
Further resolves #1966.
1 parent a955f96 commit 3ae5d5e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎nikola/plugins/command/auto/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,14 @@ def serve_static(self, environ, start_response):
300300
mimetype = 'text/html'
301301

302302
if p_uri.path == '/robots.txt':
303-
start_response('200 OK', [('Content-type', 'text/plain')])
303+
start_response('200 OK', [('Content-type', 'text/plain; charset=UTF-8')])
304304
return ['User-Agent: *\nDisallow: /\n'.encode('utf-8')]
305305
elif os.path.isfile(f_path):
306306
with open(f_path, 'rb') as fd:
307-
start_response('200 OK', [('Content-type', mimetype)])
307+
if mimetype.startswith('text/') or mimetype.endswith('+xml'):
308+
start_response('200 OK', [('Content-type', "{0}; charset=UTF-8".format(mimetype))])
309+
else:
310+
start_response('200 OK', [('Content-type', mimetype)])
308311
return [self.file_filter(mimetype, fd.read())]
309312
elif p_uri.path == '/livereload.js':
310313
with open(LRJS_PATH, 'rb') as fd:

0 commit comments

Comments
 (0)
Please sign in to comment.