changeset 11332:716e176a4e01

hgweb: specify a charset when sending raw text files Gets the charset from encoding.encoding parameter.
author Julian Cowley <julian@lava.net>
date Wed, 09 Jun 2010 12:41:44 -1000
parents 997ab9af81df
children e83aff248c17
files mercurial/hgweb/webcommands.py
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/webcommands.py	Wed Jun 09 16:39:25 2010 -0500
+++ b/mercurial/hgweb/webcommands.py	Wed Jun 09 12:41:44 2010 -1000
@@ -7,7 +7,7 @@
 
 import os, mimetypes, re, cgi, copy
 import webutil
-from mercurial import error, archival, templater, templatefilters
+from mercurial import error, encoding, archival, templater, templatefilters
 from mercurial.node import short, hex
 from mercurial.util import binary
 from common import paritygen, staticfile, get_contact, ErrorResponse
@@ -51,6 +51,8 @@
     mt = mimetypes.guess_type(path)[0]
     if mt is None:
         mt = binary(text) and 'application/octet-stream' or 'text/plain'
+    if mt.startswith('text/'):
+        mt += '; charset="%s"' % encoding.encoding
 
     req.respond(HTTP_OK, mt, path, len(text))
     return [text]