Patchwork D8935: hgweb: ignore web.templates config when guessing mime type for static content

login
register
mail settings
Submitter phabricator
Date Aug. 19, 2020, 4:42 a.m.
Message ID <differential-rev-PHID-DREV-vrrpn6c4fv2s5qultt35-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/47033/
State Superseded
Headers show

Comments

phabricator - Aug. 19, 2020, 4:42 a.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8935

AFFECTED FILES
  mercurial/hgweb/common.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py
+++ b/mercurial/hgweb/common.py
@@ -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()