changeset 45399:ec2fc4d038c2

hgweb: ignore web.templates config when guessing mime type for static content Frozen binaries won't have a file-system path for static content, so I'd like to remove dependence on that. From the documentation, it seems like `mimetypes.guess_type()` only cares about the suffix, so I think it should be enough to pass in just path under the `web.templates` directory. Differential Revision: https://phab.mercurial-scm.org/D8935
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 03 Aug 2020 23:38:50 -0700
parents dc9fe90bdbd5
children f0735f2ce542
files mercurial/hgweb/common.py
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/common.py	Sat Aug 22 16:03:44 2020 -0700
+++ b/mercurial/hgweb/common.py	Mon Aug 03 23:38:50 2020 -0700
@@ -201,7 +201,7 @@
     try:
         os.stat(path)
         ct = pycompat.sysbytes(
-            mimetypes.guess_type(pycompat.fsdecode(path))[0] or r"text/plain"
+            mimetypes.guess_type(pycompat.fsdecode(fpath))[0] or r"text/plain"
         )
         with open(path, b'rb') as fh:
             data = fh.read()