Skip to content

Commit

Permalink
Set UTF-8 charset in Content-Type in the serve command
Browse files Browse the repository at this point in the history
Resolves #1966.
  • Loading branch information
da2x committed Aug 23, 2015
1 parent c69770f commit a955f96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGES.txt
Expand Up @@ -7,6 +7,11 @@ Features
* New ``TAG_PAGES_TITLES`` and ``CATEGORY_PAGES_TITLES`` options
(Issue #1962)

Bugixes
-------

* Set UTF-8 charset in Content-Type or text/* and *+xml (Issue #1966)

New in v7.6.4
=============

Expand Down
5 changes: 4 additions & 1 deletion nikola/plugins/command/serve.py
Expand Up @@ -242,7 +242,10 @@ def send_head(self):
f.seek(0)

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

0 comments on commit a955f96

Please sign in to comment.