Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
36981:177f3b90335f | 37156:7de7bd407251 |
---|---|
115 self.do_POST() | 115 self.do_POST() |
116 | 116 |
117 def do_hgweb(self): | 117 def do_hgweb(self): |
118 self.sent_headers = False | 118 self.sent_headers = False |
119 path, query = _splitURI(self.path) | 119 path, query = _splitURI(self.path) |
120 | |
121 # Ensure the slicing of path below is valid | |
122 if (path != self.server.prefix | |
123 and not path.startswith(self.server.prefix + b'/')): | |
124 self._start_response(common.statusmessage(404), []) | |
125 self._write("Not Found") | |
126 self._done() | |
127 return | |
120 | 128 |
121 env = {} | 129 env = {} |
122 env[r'GATEWAY_INTERFACE'] = r'CGI/1.1' | 130 env[r'GATEWAY_INTERFACE'] = r'CGI/1.1' |
123 env[r'REQUEST_METHOD'] = self.command | 131 env[r'REQUEST_METHOD'] = self.command |
124 env[r'SERVER_NAME'] = self.server.server_name | 132 env[r'SERVER_NAME'] = self.server.server_name |