Edgewall Software

Ticket #5064: use_base_url_for_redirect-r6199.diff

File use_base_url_for_redirect-r6199.diff, 2.7 KB (added by cboos, 5 years ago)

Change (back?) the meaning of [trac] base_url to mean "use this as a reference URL", and don't use that for req.abs_href or req.redirects unless explicitly configured to do so, using the [trac] use_base_url_for_redirect.

  • trac/env.py

     
    8080        (''since 0.11'')""") 
    8181 
    8282    base_url = Option('trac', 'base_url', '', 
     83        """Reference URL for the Trac deployment. 
     84         
     85        This is the address that will be used when producing documents  
     86        outside of the web browsing context, in order to produce canonical 
     87        URLs.  
     88         
     89        For example, this is the address that will be used in notification 
     90        mails.""") 
     91 
     92    base_url_for_redirect = BoolOption('trac', 'use_base_url_for_redirect', 
     93            False,  
    8394        """Base URL of the Trac deployment. 
    8495         
    85         In most configurations, Trac will automatically reconstruct the URL 
     96        In some configurations, Trac can't automatically reconstruct the URL 
    8697        that is used to access it automatically. However, in more complex 
    8798        setups, usually involving running Trac behind a HTTP proxy, you may 
    88         need to use this option to force Trac to use the correct URL.""") 
     99        need to use this option to force Trac to use the base_url also for 
     100        redirects. This introduces the obvious limitation that the environment 
     101        will become usable only from that host, as redirects are quite 
     102        frequent.""") 
    89103 
    90104    project_name = Option('project', 'name', 'My Project', 
    91105        """Name of the project.""") 
  • trac/web/api.py

     
    276276 
    277277        self.send_response(status) 
    278278        if not url.startswith('http://') and not url.startswith('https://'): 
    279             # Make sure the URL is absolute, honor base_url for 
    280             # scheme and host if present 
     279            # Make sure the URL is absolute 
    281280            scheme, host = urlparse.urlparse(self.base_url)[:2] 
    282             url = urlparse.urlunparse((scheme, host, url, None, None, None))                            
     281            url = urlparse.urlunparse((scheme, host, url, None, None, None)) 
    283282 
    284283        self.send_header('Location', url) 
    285284        self.send_header('Content-Type', 'text/plain') 
  • trac/web/main.py

     
    371371    env = env_error = None 
    372372    try: 
    373373        env = open_environment(env_path, use_cache=not run_once) 
    374         if env.base_url: 
     374        if env.base_url_for_redirect: 
    375375            environ['trac.base_url'] = env.base_url 
    376376    except TracError, e: 
    377377        env_error = e