comparison mercurial/hgweb/request.py @ 36865:422be99519e5

hgweb: remove support for short query string based aliases (BC) Form data exposed by hgweb is post-processed to expand certain shortcuts. For example, URLs with "?cs=@" is essentially expanded to "?cmd=changeset&node=@". And the URL router treats this the same as "/changeset/@". These shortcuts were initially added in 2005 in 34cb3957d875 and 964baa35faf8. They have rarely been touched in the last decade (just moving code around a bit). We have almost no test coverage of this feature. AFAICT no templates reference URLs of this form. I even looked at the initial version of paper and coal from ~2008 and they use the "/command/params" URL form and not these shortcuts. Furthermore, I couldn't even get some shortcuts to work! For example, "?sl=@" attempts to do a revision search instead of showing shortlog starting at revision @. Maybe I'm just doing it wrong? Because this is ancient, mostly untested code, there is a migration path to something better, and because anyone passionate enough to preserve URLs can install URL redirects, let's nuke the feature. .. bc:: Query string shorts in hgweb like ``?cs=@`` have been removed. Use URLs of the form ``/:cmd`` instead. Differential Revision: https://phab.mercurial-scm.org/D2773
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 09 Mar 2018 17:10:36 -0800
parents 01f6bba64424
children a88d68dc3ee8
comparison
equal deleted inserted replaced
36864:01f6bba64424 36865:422be99519e5
24 ) 24 )
25 from .. import ( 25 from .. import (
26 pycompat, 26 pycompat,
27 util, 27 util,
28 ) 28 )
29
30 shortcuts = {
31 'cl': [('cmd', ['changelog']), ('rev', None)],
32 'sl': [('cmd', ['shortlog']), ('rev', None)],
33 'cs': [('cmd', ['changeset']), ('node', None)],
34 'f': [('cmd', ['file']), ('filenode', None)],
35 'fl': [('cmd', ['filelog']), ('filenode', None)],
36 'fd': [('cmd', ['filediff']), ('node', None)],
37 'fa': [('cmd', ['annotate']), ('filenode', None)],
38 'mf': [('cmd', ['manifest']), ('manifest', None)],
39 'ca': [('cmd', ['archive']), ('node', None)],
40 'tags': [('cmd', ['tags'])],
41 'tip': [('cmd', ['changeset']), ('node', ['tip'])],
42 'static': [('cmd', ['static']), ('file', None)]
43 }
44
45 def normalize(form):
46 # first expand the shortcuts
47 for k in shortcuts:
48 if k in form:
49 for name, value in shortcuts[k]:
50 if value is None:
51 value = form[k]
52 form[name] = value
53 del form[k]
54 # And strip the values
55 bytesform = {}
56 for k, v in form.iteritems():
57 bytesform[pycompat.bytesurl(k)] = [
58 pycompat.bytesurl(i.strip()) for i in v]
59 return bytesform
60 29
61 @attr.s(frozen=True) 30 @attr.s(frozen=True)
62 class parsedrequest(object): 31 class parsedrequest(object):
63 """Represents a parsed WSGI request. 32 """Represents a parsed WSGI request.
64 33
256 self.threaded = wsgienv[r'wsgi.multithread'] 225 self.threaded = wsgienv[r'wsgi.multithread']
257 self.multiprocess = wsgienv[r'wsgi.multiprocess'] 226 self.multiprocess = wsgienv[r'wsgi.multiprocess']
258 self.run_once = wsgienv[r'wsgi.run_once'] 227 self.run_once = wsgienv[r'wsgi.run_once']
259 self.env = wsgienv 228 self.env = wsgienv
260 self.req = parserequestfromenv(wsgienv, inp) 229 self.req = parserequestfromenv(wsgienv, inp)
261 self.form = normalize(self.req.querystringdict) 230 self.form = self.req.querystringdict
262 self._start_response = start_response 231 self._start_response = start_response
263 self.server_write = None 232 self.server_write = None
264 self.headers = [] 233 self.headers = []
265 234
266 def respond(self, status, type, filename=None, body=None): 235 def respond(self, status, type, filename=None, body=None):