This file is indexed.

/usr/share/pyshared/cherrypy/filters/baseurlfilter.py is in python-cherrypy 2.3.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cherrypy
from basefilter import BaseFilter


class BaseUrlFilter(BaseFilter):
    """Filter that changes the base URL.
    
    Useful when running a CP server behind Apache.
    """
    
    def before_request_body(self):
        if not cherrypy.config.get('base_url_filter.on', False):
            return
        
        request = cherrypy.request
        
        port = str(cherrypy.config.get('server.socket_port', '80'))
        if port == "80":
            defaultUrl = 'http://localhost'
        else:
            defaultUrl = 'http://localhost:%s' % port
        newBaseUrl = cherrypy.config.get('base_url_filter.base_url', defaultUrl)
        
        if cherrypy.config.get('base_url_filter.use_x_forwarded_host', True):
            newBaseUrl = request.headers.get("X-Forwarded-Host", newBaseUrl)
        
        if newBaseUrl.find("://") == -1:
            # add http:// or https:// if needed
            newBaseUrl = request.base[:request.base.find("://") + 3] + newBaseUrl
        
        request.base = newBaseUrl