[Trac-tickets] Re: [The Trac Project] #2977: Trac 0.9.4 under IIS -- corrupt redirection URL after submit

The Trac Project noreply at edgewall.com
Sun Apr 9 16:55:21 CDT 2006


#2977: Trac 0.9.4 under IIS -- corrupt redirection URL after submit
------------------------------+---------------------------------------------
 Reporter:  ewedl at sitcag.com  |        Owner:  jonas  
     Type:  defect            |       Status:  closed 
 Priority:  normal            |    Milestone:         
Component:  general           |      Version:  0.9.4  
 Severity:  major             |   Resolution:  invalid
 Keywords:                    |  
------------------------------+---------------------------------------------
Changes (by cboos):

  * status:  new => closed
  * resolution:  => invalid

Old description:

> Within the install documentation for IIS 6.0 the redirect function on the
> Request class needs to be replaced by:
>
> def redirect(self, url):
>         """Send a redirect to the client, forwarding to the specified
> URL. The
>         `url` may be relative or absolute, relative URLs will be
> translated
>         appropriately.
>         """
>         base_url = '%s://%s' % ("http", os.getenv('SERVER_NAME'))
>         if self.session:
>             self.session.save() # has to be done before the redirect is
> sent
>         self.send_response(302)
>         if not url.startswith('http://') and not
> url.startswith('https://'):
>             # Make sure the URL is absolute
>             url = absolute_url(self, url)
>         ''''''self.send_header('Location', base_url + url)''''''
>         self.send_header('Content-Type', 'text/plain')
>         self.send_header('Pragma', 'no-cache')
>         self.send_header('Cache-control', 'no-cache')
>         self.send_header('Expires', 'Fri, 01 Jan 1999 00:00:00 GMT')
>         self._send_cookie_headers()
>         self.end_headers()
>
>         if self.method != 'HEAD':
>             self.write('Redirecting...')
>
>         raise RequestDone
>
> Using this code the redirection after submission will not work -- I
> replaced
>
> self.send_header('Location', base_url + url)
>
> by
>
> self.send_header('Location', url)
>
> and the system seems to work now without any problem - pls be aware I did
> no further investigation and other cleanup - so if anybody would find a
> clean solution pls let me know

New description:

 Within the install documentation for IIS 6.0 the redirect function on the
 Request class needs to be replaced by:
 {{{
 def redirect(self, url):
         """Send a redirect to the client, forwarding to the specified URL.
 The
         `url` may be relative or absolute, relative URLs will be
 translated
         appropriately.
         """
         base_url = '%s://%s' % ("http", os.getenv('SERVER_NAME'))
         if self.session:
             self.session.save() # has to be done before the redirect is
 sent
         self.send_response(302)
         if not url.startswith('http://') and not
 url.startswith('https://'):
             # Make sure the URL is absolute
             url = absolute_url(self, url)
         ''''''self.send_header('Location', base_url + url)''''''
         self.send_header('Content-Type', 'text/plain')
         self.send_header('Pragma', 'no-cache')
         self.send_header('Cache-control', 'no-cache')
         self.send_header('Expires', 'Fri, 01 Jan 1999 00:00:00 GMT')
         self._send_cookie_headers()
         self.end_headers()

         if self.method != 'HEAD':
             self.write('Redirecting...')

         raise RequestDone
 }}}
 Using this code the redirection after submission will not work -- I
 replaced
 {{{
 self.send_header('Location', base_url + url)
 }}}
 by
 {{{
 self.send_header('Location', url)
 }}}
 and the system seems to work now without any problem - pls be aware I did
 no further investigation and other cleanup - so if anybody would find a
 clean solution pls let me know

Comment:

 Well, I don't know how you get there, but
 the `self.send_header('Location', base_url + url)` line is not part
 of the 0.9-stable branch, AFAICT.
 It has been `self.send_header('Location', url)` since r2078.

 Or maybe the version you reported is wrong. If so, please upgrade.

-- 
Ticket URL: <http://projects.edgewall.com/trac/ticket/2977>
The Trac Project <http://trac.edgewall.com/>


More information about the Trac-Tickets mailing list