Mercurial > hg
diff mercurial/hgweb/server.py @ 37156:7de7bd407251 stable 4.5.3
server: ensure the incoming request falls under the prefix value
Prior to this, the first test asserted in wsgiref.validate.check_environ()
saying PATH didn't start with '/', but the second test served up the repo. The
assertion was just added in this cycle (though the value of PATH is still wrong
without the assertion). Allowing access to the repo at any URL outside of the
prefix is a long standing bug. This also affected hgwebdir, at least when used
via --subrepo.
Paths are not being canonicalized, so accesses to things like 'foo/../bar' will
get tossed out here, unless the prefix also matches.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 01 Apr 2018 01:27:18 -0400 |
parents | b2601c5977a4 |
children | ed5448edcbfa |
line wrap: on
line diff
--- a/mercurial/hgweb/server.py Thu Mar 15 22:35:07 2018 -0700 +++ b/mercurial/hgweb/server.py Sun Apr 01 01:27:18 2018 -0400 @@ -118,6 +118,14 @@ self.sent_headers = False path, query = _splitURI(self.path) + # Ensure the slicing of path below is valid + if (path != self.server.prefix + and not path.startswith(self.server.prefix + b'/')): + self._start_response(common.statusmessage(404), []) + self._write("Not Found") + self._done() + return + env = {} env[r'GATEWAY_INTERFACE'] = r'CGI/1.1' env[r'REQUEST_METHOD'] = self.command