Skip to content

Commit

Permalink
merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Aug 24, 2015
2 parents 34509eb + 3ae5d5e commit 82b4a60
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CHANGES.txt
Expand Up @@ -11,7 +11,7 @@ Bugfixes
--------

* Add dependency on metadata file for 2-file posts (Issue #1968)

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

New in v7.6.4
=============
Expand Down
7 changes: 5 additions & 2 deletions nikola/plugins/command/auto/__init__.py
Expand Up @@ -300,11 +300,14 @@ def serve_static(self, environ, start_response):
mimetype = 'text/html'

if p_uri.path == '/robots.txt':
start_response('200 OK', [('Content-type', 'text/plain')])
start_response('200 OK', [('Content-type', 'text/plain; charset=UTF-8')])
return ['User-Agent: *\nDisallow: /\n'.encode('utf-8')]
elif os.path.isfile(f_path):
with open(f_path, 'rb') as fd:
start_response('200 OK', [('Content-type', mimetype)])
if mimetype.startswith('text/') or mimetype.endswith('+xml'):
start_response('200 OK', [('Content-type', "{0}; charset=UTF-8".format(mimetype))])
else:
start_response('200 OK', [('Content-type', mimetype)])
return [self.file_filter(mimetype, fd.read())]
elif p_uri.path == '/livereload.js':
with open(LRJS_PATH, 'rb') as fd:
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
2 changes: 1 addition & 1 deletion requirements-tests.txt
Expand Up @@ -2,7 +2,7 @@
mock==1.3.0
coverage==3.7.1
pytest==2.7.2
pytest-cov==2.0.0
pytest-cov==2.1.0
freezegun==0.3.5
python-coveralls==2.5.0
colorama==0.3.3

0 comments on commit 82b4a60

Please sign in to comment.