Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/webcommands.py @ 45397:da3b7c80aa34
hgweb: handle None from templatedir() equally bad in webcommands.py
The following paragraph is based just on my reading of the code; I
have not tried to test it.
Before my recent work on templates in frozen binaries, it seems both
`hgwebdir_mod.py` and `webcommands.py` would pass in an empty list
into `staticfile()` when running in a frozen binary. That would then
result in a variable in that function (`path`) not getting bound
before its first use. I then changed that without thinking in D8786 so
we passed a `None` value into the function, which made it break in
another way (trying to iterate over `None`). Then I tried to fix it up
in D8810, but I only changed `hgwebdir_mod.py` for some reason, and it
still doesn't actually work in frozen binaries (which seems fair,
since was broken before my changes too).
This patch just replicates the half-assed "fix" from D8810 in
`webcommands.py`, so they look more similar so I can start refactoring
them in the same way.
Differential Revision: https://phab.mercurial-scm.org/D8933
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 03 Aug 2020 22:40:05 -0700 |
parents | 9a5c4875a88c |
children | dc9fe90bdbd5 |
comparison
equal
deleted
inserted
replaced
45396:26eb62bd0550 | 45397:da3b7c80aa34 |
---|---|
1318 # a repo owner may set web.static in .hg/hgrc to get any file | 1318 # a repo owner may set web.static in .hg/hgrc to get any file |
1319 # readable by the user running the CGI script | 1319 # readable by the user running the CGI script |
1320 static = web.config(b"web", b"static", untrusted=False) | 1320 static = web.config(b"web", b"static", untrusted=False) |
1321 if not static: | 1321 if not static: |
1322 tp = web.templatepath or templater.templatedir() | 1322 tp = web.templatepath or templater.templatedir() |
1323 static = os.path.join(tp, b'static') | 1323 if tp is not None: |
1324 static = os.path.join(tp, b'static') | |
1324 | 1325 |
1325 staticfile(static, fname, web.res) | 1326 staticfile(static, fname, web.res) |
1326 return web.res.sendresponse() | 1327 return web.res.sendresponse() |
1327 | 1328 |
1328 | 1329 |