# HG changeset patch # User Julian Cowley # Date 2010-06-09 22:41:44 # Node ID 716e176a4e0123c531b641b76d906520fda4413b # Parent 997ab9af81df27edefaaf2629baaf305e68a3fb3 hgweb: specify a charset when sending raw text files Gets the charset from encoding.encoding parameter. diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py +++ b/mercurial/hgweb/webcommands.py @@ -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 @@ def rawfile(web, req, tmpl): 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]