# HG changeset patch # User Mads Kiilerich # Date 2016-07-28 16:28:34 # Node ID cf7d952c292f8b3f91bfb2a21e23e77af0125f72 # Parent 7d258b3fbc49dd14d6054991944a29428b94ee2f diff: make sure context parameter is an integer Prevent Abort in mdiff on malformed URLs. diff --git a/kallithea/controllers/compare.py b/kallithea/controllers/compare.py --- a/kallithea/controllers/compare.py +++ b/kallithea/controllers/compare.py @@ -34,7 +34,7 @@ from pylons import request, tmpl_context from pylons.i18n.translation import _ from webob.exc import HTTPFound, HTTPBadRequest -from kallithea.lib.utils2 import safe_str +from kallithea.lib.utils2 import safe_str, safe_int from kallithea.lib.vcs.utils.hgcompat import unionrepo from kallithea.lib import helpers as h from kallithea.lib.base import BaseRepoController, render @@ -201,7 +201,7 @@ class CompareController(BaseRepoControll c.ignorews_url = _ignorews_url c.context_url = _context_url ignore_whitespace = request.GET.get('ignorews') == '1' - line_context = request.GET.get('context', 3) + line_context = safe_int(request.GET.get('context'), 3) org_repo = Repository.get_by_repo_name(org_repo) other_repo = Repository.get_by_repo_name(other_repo) diff --git a/kallithea/controllers/files.py b/kallithea/controllers/files.py --- a/kallithea/controllers/files.py +++ b/kallithea/controllers/files.py @@ -42,7 +42,7 @@ from kallithea.lib import helpers as h from kallithea.lib.compat import OrderedDict from kallithea.lib.utils2 import convert_line_endings, detect_mode, safe_str, \ - str2bool + str2bool, safe_int from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator from kallithea.lib.base import BaseRepoController, render from kallithea.lib.vcs.backends.base import EmptyChangeset @@ -598,7 +598,7 @@ class FilesController(BaseRepoController 'repository.admin') def diff(self, repo_name, f_path): ignore_whitespace = request.GET.get('ignorews') == '1' - line_context = request.GET.get('context', 3) + line_context = safe_int(request.GET.get('context'), 3) diff2 = request.GET.get('diff2', '') diff1 = request.GET.get('diff1', '') or diff2 c.action = request.GET.get('diff') diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -659,7 +659,7 @@ class PullrequestsController(BaseRepoCon c.statuses = c.cs_repo.statuses(raw_ids) ignore_whitespace = request.GET.get('ignorews') == '1' - line_context = request.GET.get('context', 3) + line_context = safe_int(request.GET.get('context'), 3) c.ignorews_url = _ignorews_url c.context_url = _context_url c.fulldiff = request.GET.get('fulldiff')