"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/vcauth/forbiddenre/__init__.py" between
viewvc-1.1.28.tar.gz and viewvc-1.2.1.tar.gz

About: ViewVC is a browser interface for CVS and Subversion version control repositories.

__init__.py  (viewvc-1.1.28):__init__.py  (viewvc-1.2.1)
skipping to change at line 15 skipping to change at line 15
# By using this file, you agree to the terms and conditions set forth in # By using this file, you agree to the terms and conditions set forth in
# the LICENSE.html file which can be found at the top level of the ViewVC # the LICENSE.html file which can be found at the top level of the ViewVC
# distribution or at http://viewvc.org/license-1.html. # distribution or at http://viewvc.org/license-1.html.
# #
# For more information, visit http://viewvc.org/ # For more information, visit http://viewvc.org/
# #
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
import vcauth import vcauth
import vclib import vclib
import fnmatch import fnmatch
import string
import re import re
def _split_regexp(restr): def _split_regexp(restr):
"""Return a 2-tuple consisting of a compiled regular expression """Return a 2-tuple consisting of a compiled regular expression
object and a boolean flag indicating if that object should be object and a boolean flag indicating if that object should be
interpreted inversely.""" interpreted inversely."""
if restr[0] == '!': if restr[0] == '!':
return re.compile(restr[1:]), 1 return re.compile(restr[1:]), 1
return re.compile(restr), 0 return re.compile(restr), 0
class ViewVCAuthorizer(vcauth.GenericViewVCAuthorizer): class ViewVCAuthorizer(vcauth.GenericViewVCAuthorizer):
"""A simple regular-expression-based authorizer.""" """A simple regular-expression-based authorizer."""
def __init__(self, root_lookup_func, username, params={}): def __init__(self, root_lookup_func, username, params={}):
forbidden = params.get('forbiddenre', '') forbidden = params.get('forbiddenre', '')
self.forbidden = map(lambda x: _split_regexp(string.strip(x)), self.forbidden = map(lambda x: _split_regexp(x.strip()),
filter(None, string.split(forbidden, ','))) filter(None, forbidden.split(',')))
def _check_root_path_access(self, root_path): def _check_root_path_access(self, root_path):
default = 1 default = 1
for forbidden, negated in self.forbidden: for forbidden, negated in self.forbidden:
if negated: if negated:
default = 0 default = 0
if forbidden.search(root_path): if forbidden.search(root_path):
return 1 return 1
elif forbidden.search(root_path): elif forbidden.search(root_path):
return 0 return 0
skipping to change at line 57 skipping to change at line 56
def check_universal_access(self, rootname): def check_universal_access(self, rootname):
# If there aren't any forbidden regexps, we can grant universal # If there aren't any forbidden regexps, we can grant universal
# read access. Otherwise, we make no claim. # read access. Otherwise, we make no claim.
if not self.forbidden: if not self.forbidden:
return 1 return 1
return None return None
def check_path_access(self, rootname, path_parts, pathtype, rev=None): def check_path_access(self, rootname, path_parts, pathtype, rev=None):
root_path = rootname root_path = rootname
if path_parts: if path_parts:
root_path = root_path + '/' + string.join(path_parts, '/') root_path = root_path + '/' + '/'.join(path_parts)
if pathtype == vclib.DIR: if pathtype == vclib.DIR:
root_path = root_path + '/' root_path = root_path + '/'
else: else:
root_path = root_path + '/' root_path = root_path + '/'
return self._check_root_path_access(root_path) return self._check_root_path_access(root_path)
 End of changes. 3 change blocks. 
4 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)