Changeset - ec483ce69ad9
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 13 years ago 2012-11-28 01:34:59
marcin@python-works.com
added global fix for stripping multiple slashes from f_path variable
2 files changed with 4 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
@@ -11,48 +11,52 @@ from routes import Mapper
 
# prefix for non repository related links needs to be prefixed with `/`
 
ADMIN_PREFIX = '/_admin'
 

	
 

	
 
def make_map(config):
 
    """Create, configure and return the routes Mapper"""
 
    rmap = Mapper(directory=config['pylons.paths']['controllers'],
 
                 always_scan=config['debug'])
 
    rmap.minimization = False
 
    rmap.explicit = False
 

	
 
    from rhodecode.lib.utils import is_valid_repo
 
    from rhodecode.lib.utils import is_valid_repos_group
 

	
 
    def check_repo(environ, match_dict):
 
        """
 
        check for valid repository for proper 404 handling
 

	
 
        :param environ:
 
        :param match_dict:
 
        """
 
        from rhodecode.model.db import Repository
 
        repo_name = match_dict.get('repo_name')
 

	
 
        if match_dict.get('f_path'):
 
            #fix for multiple initial slashes that causes errors
 
            match_dict['f_path'] = match_dict['f_path'].lstrip('/')
 

	
 
        try:
 
            by_id = repo_name.split('_')
 
            if len(by_id) == 2 and by_id[1].isdigit() and by_id[0] == '':
 
                repo_name = Repository.get(by_id[1]).repo_name
 
                match_dict['repo_name'] = repo_name
 
        except:
 
            pass
 

	
 
        return is_valid_repo(repo_name, config['base_path'])
 

	
 
    def check_group(environ, match_dict):
 
        """
 
        check for valid repositories group for proper 404 handling
 

	
 
        :param environ:
 
        :param match_dict:
 
        """
 
        repos_group_name = match_dict.get('group_name')
 

	
 
        return is_valid_repos_group(repos_group_name, config['base_path'])
 

	
 
    def check_int(environ, match_dict):
 
        return match_dict.get('id').isdigit()
 

	
rhodecode/controllers/shortlog.py
Show inline comments
 
@@ -52,49 +52,48 @@ class ShortlogController(BaseRepoControl
 
        """
 
        Safe way to get changeset if error occur it redirects to tip with
 
        proper message
 

	
 
        :param rev: revision to fetch
 
        :param repo_name: repo name to redirect after
 
        """
 

	
 
        try:
 
            return c.rhodecode_repo.get_changeset(rev)
 
        except RepositoryError, e:
 
            h.flash(str(e), category='warning')
 
            redirect(h.url('shortlog_home', repo_name=repo_name))
 

	
 
    def index(self, repo_name, revision=None, f_path=None):
 
        p = safe_int(request.params.get('page', 1), 1)
 
        size = safe_int(request.params.get('size', 20), 20)
 

	
 
        def url_generator(**kw):
 
            return url('shortlog_home', repo_name=repo_name, size=size, **kw)
 

	
 
        collection = c.rhodecode_repo
 
        c.file_history = f_path
 
        if f_path:
 
            f_path = f_path.lstrip('/')
 
            # get the history for the file !
 
            tip_cs = c.rhodecode_repo.get_changeset()
 
            try:
 
                collection = tip_cs.get_file_history(f_path)
 
            except (NodeDoesNotExistError, ChangesetError):
 
                #this node is not present at tip !
 
                try:
 
                    cs = self.__get_cs_or_redirect(revision, repo_name)
 
                    collection = cs.get_file_history(f_path)
 
                except RepositoryError, e:
 
                    h.flash(str(e), category='warning')
 
                    redirect(h.url('shortlog_home', repo_name=repo_name))
 
            collection = list(reversed(collection))
 

	
 
        c.repo_changesets = RepoPage(collection, page=p,
 
                                    items_per_page=size, url=url_generator)
 
        page_revisions = [x.raw_id for x in list(collection)]
 
        c.statuses = c.rhodecode_db_repo.statuses(page_revisions)
 

	
 
        if not c.repo_changesets:
 
            h.flash(_('There are no changesets yet'), category='warning')
 
            return redirect(url('summary_home', repo_name=repo_name))
 

	
 
        c.shortlog_data = render('shortlog/shortlog_data.html')
0 comments (0 inline, 0 general)