Mercurial > hg
comparison mercurial/hgweb/webcommands.py @ 20092:77acd8ce01ce stable
hgweb: ignore non numeric "revcount" parameter values (issue4091)
author | Isaac Jurado <diptongo@gmail.com> |
---|---|
date | Fri, 08 Nov 2013 09:48:01 +0100 |
parents | 06e118c097ff |
children | 1c46b18b0e1c |
comparison
equal
deleted
inserted
replaced
20076:faa4b3fc4197 | 20092:77acd8ce01ce |
---|---|
226 break | 226 break |
227 | 227 |
228 query = req.form['rev'][0] | 228 query = req.form['rev'][0] |
229 revcount = web.maxchanges | 229 revcount = web.maxchanges |
230 if 'revcount' in req.form: | 230 if 'revcount' in req.form: |
231 revcount = int(req.form.get('revcount', [revcount])[0]) | 231 try: |
232 revcount = max(revcount, 1) | 232 revcount = int(req.form.get('revcount', [revcount])[0]) |
233 tmpl.defaults['sessionvars']['revcount'] = revcount | 233 revcount = max(revcount, 1) |
234 tmpl.defaults['sessionvars']['revcount'] = revcount | |
235 except ValueError: | |
236 pass | |
234 | 237 |
235 lessvars = copy.copy(tmpl.defaults['sessionvars']) | 238 lessvars = copy.copy(tmpl.defaults['sessionvars']) |
236 lessvars['revcount'] = max(revcount / 2, 1) | 239 lessvars['revcount'] = max(revcount / 2, 1) |
237 lessvars['rev'] = query | 240 lessvars['rev'] = query |
238 morevars = copy.copy(tmpl.defaults['sessionvars']) | 241 morevars = copy.copy(tmpl.defaults['sessionvars']) |
305 "branches": webutil.nodebranchdict(web.repo, ctx) | 308 "branches": webutil.nodebranchdict(web.repo, ctx) |
306 } | 309 } |
307 | 310 |
308 revcount = shortlog and web.maxshortchanges or web.maxchanges | 311 revcount = shortlog and web.maxshortchanges or web.maxchanges |
309 if 'revcount' in req.form: | 312 if 'revcount' in req.form: |
310 revcount = int(req.form.get('revcount', [revcount])[0]) | 313 try: |
311 revcount = max(revcount, 1) | 314 revcount = int(req.form.get('revcount', [revcount])[0]) |
312 tmpl.defaults['sessionvars']['revcount'] = revcount | 315 revcount = max(revcount, 1) |
316 tmpl.defaults['sessionvars']['revcount'] = revcount | |
317 except ValueError: | |
318 pass | |
313 | 319 |
314 lessvars = copy.copy(tmpl.defaults['sessionvars']) | 320 lessvars = copy.copy(tmpl.defaults['sessionvars']) |
315 lessvars['revcount'] = max(revcount / 2, 1) | 321 lessvars['revcount'] = max(revcount / 2, 1) |
316 morevars = copy.copy(tmpl.defaults['sessionvars']) | 322 morevars = copy.copy(tmpl.defaults['sessionvars']) |
317 morevars['revcount'] = revcount * 2 | 323 morevars['revcount'] = revcount * 2 |
820 frev -= 1 | 826 frev -= 1 |
821 fctx = web.repo.filectx(f, fl.linkrev(frev)) | 827 fctx = web.repo.filectx(f, fl.linkrev(frev)) |
822 | 828 |
823 revcount = web.maxshortchanges | 829 revcount = web.maxshortchanges |
824 if 'revcount' in req.form: | 830 if 'revcount' in req.form: |
825 revcount = int(req.form.get('revcount', [revcount])[0]) | 831 try: |
826 revcount = max(revcount, 1) | 832 revcount = int(req.form.get('revcount', [revcount])[0]) |
827 tmpl.defaults['sessionvars']['revcount'] = revcount | 833 revcount = max(revcount, 1) |
834 tmpl.defaults['sessionvars']['revcount'] = revcount | |
835 except ValueError: | |
836 pass | |
828 | 837 |
829 lessvars = copy.copy(tmpl.defaults['sessionvars']) | 838 lessvars = copy.copy(tmpl.defaults['sessionvars']) |
830 lessvars['revcount'] = max(revcount / 2, 1) | 839 lessvars['revcount'] = max(revcount / 2, 1) |
831 morevars = copy.copy(tmpl.defaults['sessionvars']) | 840 morevars = copy.copy(tmpl.defaults['sessionvars']) |
832 morevars['revcount'] = revcount * 2 | 841 morevars['revcount'] = revcount * 2 |
943 rev = ctx.rev() | 952 rev = ctx.rev() |
944 | 953 |
945 bg_height = 39 | 954 bg_height = 39 |
946 revcount = web.maxshortchanges | 955 revcount = web.maxshortchanges |
947 if 'revcount' in req.form: | 956 if 'revcount' in req.form: |
948 revcount = int(req.form.get('revcount', [revcount])[0]) | 957 try: |
949 revcount = max(revcount, 1) | 958 revcount = int(req.form.get('revcount', [revcount])[0]) |
950 tmpl.defaults['sessionvars']['revcount'] = revcount | 959 revcount = max(revcount, 1) |
960 tmpl.defaults['sessionvars']['revcount'] = revcount | |
961 except ValueError: | |
962 pass | |
951 | 963 |
952 lessvars = copy.copy(tmpl.defaults['sessionvars']) | 964 lessvars = copy.copy(tmpl.defaults['sessionvars']) |
953 lessvars['revcount'] = max(revcount / 2, 1) | 965 lessvars['revcount'] = max(revcount / 2, 1) |
954 morevars = copy.copy(tmpl.defaults['sessionvars']) | 966 morevars = copy.copy(tmpl.defaults['sessionvars']) |
955 morevars['revcount'] = revcount * 2 | 967 morevars['revcount'] = revcount * 2 |