Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1003

Show
Ignore:
Timestamp:
03/10/06 02:58:25
Author:
rdelon
Message:

PEP8ifying static filter

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/filters/staticfilter.py

    r927 r1003  
    2727        filename = config.get('static_filter.file') 
    2828        if filename: 
    29             staticDir = None 
     29            static_dir = None 
    3030        else: 
    31             staticDir = config.get('static_filter.dir') 
    32             if not staticDir: 
     31            static_dir = config.get('static_filter.dir') 
     32            if not static_dir: 
    3333                msg = ("StaticFilter requires either static_filter.file " 
    3434                       "or static_filter.dir (%s)" % request.path) 
    3535                raise cherrypy.WrongConfigValue(msg) 
    36             section = config.get('static_filter.dir', return_section=True) 
     36            section = config.get('static_filter.dir', return_section = True) 
    3737            if section == 'global': 
    3838                section = "/" 
    3939            section = section.rstrip(r"\/") 
    40             extraPath = path[len(section) + 1:] 
    41             extraPath = extraPath.lstrip(r"\/") 
    42             extraPath = urllib.unquote(extraPath) 
    43             # If extraPath is "", filename will end in a slash 
    44             filename = os.path.join(staticDir, extraPath) 
     40            extra_path = path[len(section) + 1:] 
     41            extra_path = extra_path.lstrip(r"\/") 
     42            extra_path = urllib.unquote(extra_path) 
     43            # If extra_path is "", filename will end in a slash 
     44            filename = os.path.join(static_dir, extra_path) 
    4545         
    4646        # If filename is relative, make absolute using "root". 
     
    5555         
    5656        # If we used static_filter.dir, then there's a chance that the 
    57         # extraPath pulled from the URL might have ".." or similar uplevel 
    58         # attacks in it. Check that the final file is a child of staticDir. 
     57        # extra_path pulled from the URL might have ".." or similar uplevel 
     58        # attacks in it. Check that the final file is a child of static_dir. 
    5959        # Note that we do not check static_filter.file--that can point 
    6060        # anywhere (since it does not use the request URL). 
    61         if staticDir: 
    62             if not os.path.isabs(staticDir): 
    63                 staticDir = os.path.join(root, staticDir) 
    64             if not os.path.normpath(filename).startswith(os.path.normpath(staticDir)): 
     61        if static_dir: 
     62            if not os.path.isabs(static_dir): 
     63                static_dir = os.path.join(root, static_dir) 
     64            if not os.path.normpath(filename).startswith(os.path.normpath(static_dir)): 
    6565                raise cherrypy.HTTPError(403) # Forbidden 
    6666             

Hosted by WebFaction

Log in as guest/cpguest to create tickets