diff -r 011eec5a66b2 -r 3972d090aba2 mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py Tue Dec 19 21:36:52 2023 +0100 +++ b/mercurial/hgweb/hgwebdir_mod.py Tue Dec 19 21:38:46 2023 +0100 @@ -410,15 +410,15 @@ gc.collect(generation=1) def _runwsgi(self, req, res): - try: - self.refresh() + self.refresh() - csp, nonce = cspvalues(self.ui) - if csp: - res.headers[b'Content-Security-Policy'] = csp + csp, nonce = cspvalues(self.ui) + if csp: + res.headers[b'Content-Security-Policy'] = csp - virtual = req.dispatchpath.strip(b'/') - tmpl = self.templater(req, nonce) + virtual = req.dispatchpath.strip(b'/') + tmpl = self.templater(req, nonce) + try: ctype = tmpl.render(b'mimetype', {b'encoding': encoding.encoding}) # Global defaults. These can be overridden by any handler.