Skip to content

Commit a955f96

Browse files
committedAug 23, 2015
Set UTF-8 charset in Content-Type in the serve command
Resolves #1966.
1 parent c69770f commit a955f96

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
 

‎CHANGES.txt

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ Features
77
* New ``TAG_PAGES_TITLES`` and ``CATEGORY_PAGES_TITLES`` options
88
(Issue #1962)
99

10+
Bugixes
11+
-------
12+
13+
* Set UTF-8 charset in Content-Type or text/* and *+xml (Issue #1966)
14+
1015
New in v7.6.4
1116
=============
1217

‎nikola/plugins/command/serve.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,10 @@ def send_head(self):
242242
f.seek(0)
243243

244244
self.send_response(200)
245-
self.send_header("Content-type", ctype)
245+
if ctype.startswith('text/') or ctype.endswith('+xml'):
246+
self.send_header("Content-Type", "{0}; charset=UTF-8".format(ctype))
247+
else:
248+
self.send_header("Content-Type", ctype)
246249
if os.path.splitext(path)[1] == '.svgz':
247250
# Special handling for svgz to make it work nice with browsers.
248251
self.send_header("Content-Encoding", 'gzip')

0 commit comments

Comments
 (0)
Please sign in to comment.