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

Changeset 909

Show
Ignore:
Timestamp:
01/02/06 15:12:13
Author:
fumanchu
Message:

Fix for #430 (serveFile should require abs paths).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/lib/cptools.py

    r896 r909  
    7676    response = cherrypy.response 
    7777     
    78     # If path is relative, make absolute using cherrypy.root's module. 
    79     # If there is no cherrypy.root, or it doesn't have a __module__ 
    80     # attribute, then users should fix the issue by making path absolute. 
    81     # That is, CherryPy should not guess where the application root is 
    82     # any further than trying cherrypy.root.__module__, and it certainly 
    83     # should *not* use cwd (since CP may be invoked from a variety of 
    84     # paths). If using static_filter, you can make your relative paths 
    85     # become absolute by supplying a value for "static_filter.root". 
     78    # If path is relative, users should fix it by making path absolute. 
     79    # That is, CherryPy should not guess where the application root is. 
     80    # It certainly should *not* use cwd (since CP may be invoked from a 
     81    # variety of paths). If using static_filter, you can make your relative 
     82    # paths become absolute by supplying a value for "static_filter.root". 
    8683    if not os.path.isabs(path): 
    87         root = os.path.dirname(sys.modules[cherrypy.root.__module__].__file__) 
    88         path = os.path.join(root, path) 
     84        raise ValueError("'%s' is not an absolute path." % path) 
    8985     
    9086    try: 
  • trunk/cherrypy/test/test_static_filter.py

    r900 r909  
    3535        'static_filter.on': True, 
    3636        'static_filter.dir': 'static', 
     37        'static_filter.root': curdir, 
    3738    }, 
    3839    '/style.css': { 
    3940        'static_filter.on': True, 
    4041        'static_filter.file': 'style.css', 
     42        'static_filter.root': curdir, 
    4143    }, 
    4244    '/docroot': { 
     
    5759     
    5860    def testStaticFilter(self): 
    59         # This should resolve relative to cherrypy.root.__module__. 
    6061        self.getPage("/static/index.html") 
    6162        self.assertStatus('200 OK') 
     
    6364        self.assertBody('Hello, world\r\n') 
    6465         
    65         # Using a static_filter.root value... 
     66        # Using a static_filter.root value in a subdir... 
    6667        self.getPage("/docroot/index.html") 
    6768        self.assertStatus('200 OK') 

Hosted by WebFaction

Log in as guest/cpguest to create tickets