Show More
@@ -40,7 +40,7 b' from rhodecode.lib import helpers as h' | |||||
40 | from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \ |
|
40 | from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator, \ | |
41 | HasPermissionAnyDecorator |
|
41 | HasPermissionAnyDecorator | |
42 | from rhodecode.lib.base import BaseController, render |
|
42 | from rhodecode.lib.base import BaseController, render | |
43 | from rhodecode.lib.utils import invalidate_cache, action_logger |
|
43 | from rhodecode.lib.utils import invalidate_cache, action_logger, repo_name_slug | |
44 | from rhodecode.model.db import User |
|
44 | from rhodecode.model.db import User | |
45 | from rhodecode.model.forms import RepoForm |
|
45 | from rhodecode.model.forms import RepoForm | |
46 | from rhodecode.model.scm import ScmModel |
|
46 | from rhodecode.model.scm import ScmModel | |
@@ -118,7 +118,7 b' class ReposController(BaseController):' | |||||
118 | def new(self, format='html'): |
|
118 | def new(self, format='html'): | |
119 | """GET /repos/new: Form to create a new item""" |
|
119 | """GET /repos/new: Form to create a new item""" | |
120 | new_repo = request.GET.get('repo', '') |
|
120 | new_repo = request.GET.get('repo', '') | |
121 |
c.new_repo = |
|
121 | c.new_repo = repo_name_slug(new_repo) | |
122 |
|
122 | |||
123 | return render('admin/repos/repo_add.html') |
|
123 | return render('admin/repos/repo_add.html') | |
124 |
|
124 |
@@ -29,7 +29,7 b' import logging' | |||||
29 | import traceback |
|
29 | import traceback | |
30 | import formencode |
|
30 | import formencode | |
31 |
|
31 | |||
32 | from operator import itemgetter |
|
32 | from sqlalchemy import func | |
33 | from formencode import htmlfill |
|
33 | from formencode import htmlfill | |
34 | from pylons import request, session, tmpl_context as c, url, app_globals as g, \ |
|
34 | from pylons import request, session, tmpl_context as c, url, app_globals as g, \ | |
35 | config |
|
35 | config | |
@@ -50,8 +50,6 b' from rhodecode.model.scm import ScmModel' | |||||
50 | from rhodecode.model.settings import SettingsModel |
|
50 | from rhodecode.model.settings import SettingsModel | |
51 | from rhodecode.model.user import UserModel |
|
51 | from rhodecode.model.user import UserModel | |
52 |
|
52 | |||
53 | from sqlalchemy import func |
|
|||
54 |
|
||||
55 |
|
53 | |||
56 | log = logging.getLogger(__name__) |
|
54 | log = logging.getLogger(__name__) | |
57 |
|
55 | |||
@@ -324,7 +322,7 b' class SettingsController(BaseController)' | |||||
324 | def create_repository(self): |
|
322 | def create_repository(self): | |
325 | """GET /_admin/create_repository: Form to create a new item""" |
|
323 | """GET /_admin/create_repository: Form to create a new item""" | |
326 | new_repo = request.GET.get('repo', '') |
|
324 | new_repo = request.GET.get('repo', '') | |
327 |
c.new_repo = |
|
325 | c.new_repo = repo_name_slug(new_repo) | |
328 |
|
326 | |||
329 | return render('admin/repos/repo_add_create_repository.html') |
|
327 | return render('admin/repos/repo_add_create_repository.html') | |
330 |
|
328 |
@@ -8,9 +8,11 b' import hashlib' | |||||
8 | import StringIO |
|
8 | import StringIO | |
9 | from pygments.formatters import HtmlFormatter |
|
9 | from pygments.formatters import HtmlFormatter | |
10 | from pygments import highlight as code_highlight |
|
10 | from pygments import highlight as code_highlight | |
11 |
from pylons import url |
|
11 | from pylons import url | |
12 | from pylons.i18n.translation import _, ungettext |
|
12 | from pylons.i18n.translation import _, ungettext | |
13 | from vcs.utils.annotate import annotate_highlight |
|
13 | from vcs.utils.annotate import annotate_highlight | |
|
14 | from rhodecode.lib.utils import repo_name_slug | |||
|
15 | ||||
14 | from webhelpers.html import literal, HTML, escape |
|
16 | from webhelpers.html import literal, HTML, escape | |
15 | from webhelpers.html.tools import * |
|
17 | from webhelpers.html.tools import * | |
16 | from webhelpers.html.builder import make_tag |
|
18 | from webhelpers.html.builder import make_tag | |
@@ -73,23 +75,6 b' class _GetError(object):' | |||||
73 |
|
75 | |||
74 | get_error = _GetError() |
|
76 | get_error = _GetError() | |
75 |
|
77 | |||
76 | def recursive_replace(str, replace=' '): |
|
|||
77 | """Recursive replace of given sign to just one instance |
|
|||
78 |
|
||||
79 | :param str: given string |
|
|||
80 | :param replace: char to find and replace multiple instances |
|
|||
81 |
|
||||
82 | Examples:: |
|
|||
83 | >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-') |
|
|||
84 | 'Mighty-Mighty-Bo-sstones' |
|
|||
85 | """ |
|
|||
86 |
|
||||
87 | if str.find(replace * 2) == -1: |
|
|||
88 | return str |
|
|||
89 | else: |
|
|||
90 | str = str.replace(replace * 2, replace) |
|
|||
91 | return recursive_replace(str, replace) |
|
|||
92 |
|
||||
93 | class _ToolTip(object): |
|
78 | class _ToolTip(object): | |
94 |
|
79 | |||
95 | def __call__(self, tooltip_title, trim_at=50): |
|
80 | def __call__(self, tooltip_title, trim_at=50): | |
@@ -357,21 +342,6 b' def pygmentize_annotation(filenode, **kw' | |||||
357 | return uri |
|
342 | return uri | |
358 | return literal(annotate_highlight(filenode, url_func, **kwargs)) |
|
343 | return literal(annotate_highlight(filenode, url_func, **kwargs)) | |
359 |
|
344 | |||
360 | def repo_name_slug(value): |
|
|||
361 | """Return slug of name of repository |
|
|||
362 | This function is called on each creation/modification |
|
|||
363 | of repository to prevent bad names in repo |
|
|||
364 | """ |
|
|||
365 |
|
||||
366 | slug = remove_formatting(value) |
|
|||
367 | slug = strip_tags(slug) |
|
|||
368 |
|
||||
369 | for c in """=[]\;'"<>,/~!@#$%^&*()+{}|: """: |
|
|||
370 | slug = slug.replace(c, '-') |
|
|||
371 | slug = recursive_replace(slug, '-') |
|
|||
372 | slug = collapse(slug, '-') |
|
|||
373 | return slug |
|
|||
374 |
|
||||
375 | def get_changeset_safe(repo, rev): |
|
345 | def get_changeset_safe(repo, rev): | |
376 | from vcs.backends.base import BaseRepository |
|
346 | from vcs.backends.base import BaseRepository | |
377 | from vcs.exceptions import RepositoryError |
|
347 | from vcs.exceptions import RepositoryError |
@@ -29,15 +29,17 b' import os' | |||||
29 | import logging |
|
29 | import logging | |
30 | import datetime |
|
30 | import datetime | |
31 | import traceback |
|
31 | import traceback | |
|
32 | import paste | |||
|
33 | import beaker | |||
|
34 | ||||
|
35 | from paste.script.command import Command, BadCommand | |||
32 |
|
36 | |||
33 | from UserDict import DictMixin |
|
37 | from UserDict import DictMixin | |
34 |
|
38 | |||
35 | from mercurial import ui, config, hg |
|
39 | from mercurial import ui, config, hg | |
36 | from mercurial.error import RepoError |
|
40 | from mercurial.error import RepoError | |
37 |
|
41 | |||
38 | import paste |
|
42 | from webhelpers.text import collapse, remove_formatting, strip_tags | |
39 | import beaker |
|
|||
40 | from paste.script.command import Command, BadCommand |
|
|||
41 |
|
43 | |||
42 | from vcs.backends.base import BaseChangeset |
|
44 | from vcs.backends.base import BaseChangeset | |
43 | from vcs.utils.lazy import LazyProperty |
|
45 | from vcs.utils.lazy import LazyProperty | |
@@ -51,6 +53,38 b' from rhodecode.model.user import UserMod' | |||||
51 | log = logging.getLogger(__name__) |
|
53 | log = logging.getLogger(__name__) | |
52 |
|
54 | |||
53 |
|
55 | |||
|
56 | def recursive_replace(str, replace=' '): | |||
|
57 | """Recursive replace of given sign to just one instance | |||
|
58 | ||||
|
59 | :param str: given string | |||
|
60 | :param replace: char to find and replace multiple instances | |||
|
61 | ||||
|
62 | Examples:: | |||
|
63 | >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-') | |||
|
64 | 'Mighty-Mighty-Bo-sstones' | |||
|
65 | """ | |||
|
66 | ||||
|
67 | if str.find(replace * 2) == -1: | |||
|
68 | return str | |||
|
69 | else: | |||
|
70 | str = str.replace(replace * 2, replace) | |||
|
71 | return recursive_replace(str, replace) | |||
|
72 | ||||
|
73 | def repo_name_slug(value): | |||
|
74 | """Return slug of name of repository | |||
|
75 | This function is called on each creation/modification | |||
|
76 | of repository to prevent bad names in repo | |||
|
77 | """ | |||
|
78 | ||||
|
79 | slug = remove_formatting(value) | |||
|
80 | slug = strip_tags(slug) | |||
|
81 | ||||
|
82 | for c in """=[]\;'"<>,/~!@#$%^&*()+{}|: """: | |||
|
83 | slug = slug.replace(c, '-') | |||
|
84 | slug = recursive_replace(slug, '-') | |||
|
85 | slug = collapse(slug, '-') | |||
|
86 | return slug | |||
|
87 | ||||
54 | def get_repo_slug(request): |
|
88 | def get_repo_slug(request): | |
55 | return request.environ['pylons.routes_dict'].get('repo_name') |
|
89 | return request.environ['pylons.routes_dict'].get('repo_name') | |
56 |
|
90 |
@@ -29,8 +29,9 b' from formencode.validators import Unicod' | |||||
29 | Email, Bool, StringBoolean, Set |
|
29 | Email, Bool, StringBoolean, Set | |
30 |
|
30 | |||
31 | from pylons.i18n.translation import _ |
|
31 | from pylons.i18n.translation import _ | |
|
32 | from webhelpers.pylonslib.secure_form import authentication_token | |||
32 |
|
33 | |||
33 | import rhodecode.lib.helpers as h |
|
34 | from rhodecode.lib.utils import repo_name_slug | |
34 | from rhodecode.lib.auth import authenticate, get_crypt_password |
|
35 | from rhodecode.lib.auth import authenticate, get_crypt_password | |
35 | from rhodecode.lib.exceptions import LdapImportError |
|
36 | from rhodecode.lib.exceptions import LdapImportError | |
36 | from rhodecode.model import meta |
|
37 | from rhodecode.model import meta | |
@@ -40,8 +41,6 b' from rhodecode.model.users_group import ' | |||||
40 | from rhodecode.model.db import User, UsersGroup |
|
41 | from rhodecode.model.db import User, UsersGroup | |
41 | from rhodecode import BACKENDS |
|
42 | from rhodecode import BACKENDS | |
42 |
|
43 | |||
43 | from webhelpers.pylonslib.secure_form import authentication_token |
|
|||
44 |
|
||||
45 | log = logging.getLogger(__name__) |
|
44 | log = logging.getLogger(__name__) | |
46 |
|
45 | |||
47 | #this is needed to translate the messages using _() in validators |
|
46 | #this is needed to translate the messages using _() in validators | |
@@ -214,7 +213,7 b' def ValidRepoName(edit, old_data):' | |||||
214 | class _ValidRepoName(formencode.validators.FancyValidator): |
|
213 | class _ValidRepoName(formencode.validators.FancyValidator): | |
215 |
|
214 | |||
216 | def to_python(self, value, state): |
|
215 | def to_python(self, value, state): | |
217 |
slug = |
|
216 | slug = repo_name_slug(value) | |
218 | if slug in ['_admin']: |
|
217 | if slug in ['_admin']: | |
219 | raise formencode.Invalid(_('This repository name is disallowed'), |
|
218 | raise formencode.Invalid(_('This repository name is disallowed'), | |
220 | value, state) |
|
219 | value, state) |
@@ -29,30 +29,29 b' import time' | |||||
29 | import traceback |
|
29 | import traceback | |
30 | import logging |
|
30 | import logging | |
31 |
|
31 | |||
|
32 | from mercurial import ui | |||
|
33 | ||||
|
34 | from sqlalchemy.orm import joinedload | |||
|
35 | from sqlalchemy.orm.session import make_transient | |||
|
36 | from sqlalchemy.exc import DatabaseError | |||
|
37 | ||||
|
38 | from beaker.cache import cache_region, region_invalidate | |||
|
39 | ||||
32 | from vcs import get_backend |
|
40 | from vcs import get_backend | |
33 | from vcs.utils.helpers import get_scm |
|
41 | from vcs.utils.helpers import get_scm | |
34 | from vcs.exceptions import RepositoryError, VCSError |
|
42 | from vcs.exceptions import RepositoryError, VCSError | |
35 | from vcs.utils.lazy import LazyProperty |
|
43 | from vcs.utils.lazy import LazyProperty | |
36 |
|
44 | |||
37 | from mercurial import ui |
|
|||
38 |
|
||||
39 | from beaker.cache import cache_region, region_invalidate |
|
|||
40 |
|
||||
41 | from rhodecode import BACKENDS |
|
45 | from rhodecode import BACKENDS | |
42 | from rhodecode.lib import helpers as h |
|
46 | from rhodecode.lib import helpers as h | |
43 | from rhodecode.lib.auth import HasRepoPermissionAny |
|
47 | from rhodecode.lib.auth import HasRepoPermissionAny | |
44 | from rhodecode.lib.utils import get_repos as get_filesystem_repos, make_ui, action_logger |
|
48 | from rhodecode.lib.utils import get_repos as get_filesystem_repos, make_ui, action_logger | |
45 | from rhodecode.model import BaseModel |
|
49 | from rhodecode.model import BaseModel | |
46 | from rhodecode.model.user import UserModel |
|
50 | from rhodecode.model.user import UserModel | |
47 |
|
||||
48 | from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \ |
|
51 | from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \ | |
49 | UserFollowing, UserLog |
|
52 | UserFollowing, UserLog | |
50 | from rhodecode.model.caching_query import FromCache |
|
53 | from rhodecode.model.caching_query import FromCache | |
51 |
|
54 | |||
52 | from sqlalchemy.orm import joinedload |
|
|||
53 | from sqlalchemy.orm.session import make_transient |
|
|||
54 | from sqlalchemy.exc import DatabaseError |
|
|||
55 |
|
||||
56 | log = logging.getLogger(__name__) |
|
55 | log = logging.getLogger(__name__) | |
57 |
|
56 | |||
58 |
|
57 |
General Comments 0
You need to be logged in to leave comments.
Login now