aboutsummaryrefslogtreecommitdiff
path: root/rhodecode/model/forms.py
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2011-04-16 21:05:21 +0200
committerMarcin Kuzminski <marcin@python-works.com>2011-04-16 21:05:21 +0200
commitc78b1090cb4f852e090dd056fedf36519aa3d07c (patch)
tree75a3529c15443464c7c5734fae1b95e2201553f6 /rhodecode/model/forms.py
parentf3168a0ffd5c56360ccd55ae6ea774ffbd4be902 (diff)
added dump validation of cloneurl, it can still freeze if server will ask for auth.
--HG-- branch : beta
Diffstat (limited to 'rhodecode/model/forms.py')
-rw-r--r--rhodecode/model/forms.py34
1 files changed, 31 insertions, 3 deletions
diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py
index e60903c9..47847305 100644
--- a/rhodecode/model/forms.py
+++ b/rhodecode/model/forms.py
@@ -226,13 +226,40 @@ def ValidRepoName(edit, old_data):
return _ValidRepoName
+def ValidCloneUri():
+ from mercurial.httprepo import httprepository, httpsrepository
+ from rhodecode.lib.utils import make_ui
+
+ class _ValidCloneUri(formencode.validators.FancyValidator):
+ def to_python(self, value, state):
+ if not value:
+ pass
+ elif value.startswith('https'):
+ try:
+ httpsrepository(make_ui('db'), value).capabilities()
+ except:
+ raise formencode.Invalid(_('invalid clone url'), value,
+ state)
+ elif value.startswith('http'):
+ try:
+ httprepository(make_ui('db'), value).capabilities()
+ except:
+ raise formencode.Invalid(_('invalid clone url'), value,
+ state)
+ else:
+ raise formencode.Invalid(_('Invalid clone url, provide a '
+ 'valid clone http\s url'), value,
+ state)
+
+ return _ValidCloneUri
+
def ValidForkType(old_data):
class _ValidForkType(formencode.validators.FancyValidator):
def to_python(self, value, state):
if old_data['repo_type'] != value:
- raise formencode.Invalid(_('Fork have to be the same type as original'),
- value, state)
+ raise formencode.Invalid(_('Fork have to be the same '
+ 'type as original'), value, state)
return value
return _ValidForkType
@@ -457,7 +484,8 @@ def RepoForm(edit=False, old_data={}, supported_backends=BACKENDS.keys(),
filter_extra_fields = False
repo_name = All(UnicodeString(strip=True, min=1, not_empty=True),
ValidRepoName(edit, old_data))
- clone_uri = UnicodeString(strip=True, min=1, not_empty=False)
+ clone_uri = All(UnicodeString(strip=True, min=1, not_empty=False),
+ ValidCloneUri()())
repo_group = OneOf(repo_groups, hideList=True)
repo_type = OneOf(supported_backends)
description = UnicodeString(strip=True, min=1, not_empty=True)