##// END OF EJS Templates
hgweb: explicitly check if requested command exists
Dirkjan Ochtman -
r5963:5be210af default
parent child Browse files
Show More
@@ -202,17 +202,18 b' class hgweb(object):'
202 202 try:
203 203
204 204 cmd = req.form.get('cmd', [''])[0]
205 if hasattr(protocol, cmd):
205 if cmd in protocol.__all__:
206 206 method = getattr(protocol, cmd)
207 207 method(self, req)
208 208 else:
209
210 209 tmpl = self.templater(req)
211 210 if cmd == '':
212 211 req.form['cmd'] = [tmpl.cache['default']]
213 212 cmd = req.form['cmd'][0]
214 213
215 if cmd == 'file' and 'raw' in req.form.get('style', []):
214 if cmd not in webcommands.__all__:
215 raise ErrorResponse(400, 'No such method: ' + cmd)
216 elif cmd == 'file' and 'raw' in req.form.get('style', []):
216 217 webcommands.rawfile(self, req, tmpl)
217 218 else:
218 219 getattr(webcommands, cmd)(self, req, tmpl)
@@ -227,8 +228,6 b' class hgweb(object):'
227 228 tmpl('error', error=str(inst)))
228 229 except ErrorResponse, inst:
229 230 req.respond(inst.code, tmpl('error', error=inst.message))
230 except AttributeError:
231 req.respond(400, tmpl('error', error='No such method: ' + cmd))
232 231
233 232 def templater(self, req):
234 233
@@ -10,6 +10,14 b' from mercurial import util, streamclone'
10 10 from mercurial.i18n import gettext as _
11 11 from mercurial.node import *
12 12
13 # __all__ is populated with the allowed commands. Be sure to add to it if
14 # you're adding a new command, or the new command won't work.
15
16 __all__ = [
17 'lookup', 'heads', 'branches', 'between', 'changegroup',
18 'changegroupsubset', 'capabilities', 'unbundle', 'stream_out',
19 ]
20
13 21 def lookup(web, req):
14 22 try:
15 23 r = hex(web.repo.lookup(req.form['key'][0]))
@@ -9,6 +9,15 b' import os, mimetypes'
9 9 from mercurial import revlog, util, hg
10 10 from common import staticfile, ErrorResponse
11 11
12 # __all__ is populated with the allowed commands. Be sure to add to it if
13 # you're adding a new command, or the new command won't work.
14
15 __all__ = [
16 'log', 'rawfile', 'file', 'changelog', 'shortlog', 'changeset', 'rev',
17 'manifest', 'tags', 'summary', 'filediff', 'diff', 'annotate', 'filelog',
18 'archive', 'static',
19 ]
20
12 21 def log(web, req, tmpl):
13 22 if 'file' in req.form and req.form['file'][0]:
14 23 filelog(web, req, tmpl)
General Comments 0
You need to be logged in to leave comments. Login now