Edgewall Software

Ticket #2553: https_post_redirect2.patch

File https_post_redirect2.patch, 1.0 KB (added by pkoelle@…, 2 years ago)

honor base_url in Request.redirect()

  • trac/web/api.py

    old new  
    325325 
    326326        self.send_response(status) 
    327327        if not url.startswith('http://') and not url.startswith('https://'): 
    328             # Make sure the URL is absolute 
    329             url = urlparse.urlunparse((self.scheme, 
    330                                        urlparse.urlparse(self.base_url)[1], 
    331                                        url, None, None, None)) 
     328            # Make sure the URL is absolute, honor base_url for 
     329            # scheme and host if present 
     330            scheme, host, path, params, query, fragment = urlparse.urlparse( 
     331                                                              self.abs_href()) 
     332            url = urlparse.urlunparse((scheme, host, url, None, None, None))                            
     333 
    332334        self.send_header('Location', url) 
    333335        self.send_header('Content-Type', 'text/plain') 
    334336        self.send_header('Pragma', 'no-cache')