Forum OpenACS Development: Infinite Redirect-Loop in Request Processor [+PATCH] (host-node maps)

There is an infinite-redirect loop in the request processor that occurs when the user accesses a subsite which has a host_node_map and the URL contains the path to the subsite as its prefix. For example, if there was a subsite named mysubsite on OpenACS.org with a host_node_map entry associating it with mysubsite.openacs.org, then accessing the (hypothetical) image at the URL http://mysubsite.openacs.org/mysubsite/images/logo.png would lead to an infinite-redirect loop (client is immediately redirected back to http://mysubsite.openacs.org/mysubsite/images/logo.png).

The problem occurs because the URL that is modified is not being sent back to the user. The user gets the original URL. The fix is to use the modified $url variable instead of the un-modified $ad_conn_url.

Here is a patch:

--- request-processor-procs.tcl
+++ request-processor-procs.tcl
@@ -550,25 +550,25 @@
     #                         remove this prefix from the URL, and redirect.
     if { $root ne "" } {
         if { [regexp "^${root}(.*)$" $ad_conn_url match url] } {
 
             if { [regexp {^GET [^\?]*\?(.*) HTTP} [ns_conn request] match vars] } {
                 append url ?$vars
             }
             if { [security::secure_conn_p] } {
                 # it's a secure connection.
                 ad_returnredirect \
-                    -allow_complete_url https://[ad_host][ad_port]$ad_conn_url
+                    -allow_complete_url https://[ad_host][ad_port]$url
                 return "filter_return"
             } else {
                 ad_returnredirect \
-                    -allow_complete_url http://[ad_host][ad_port]$ad_conn_url
+                    -allow_complete_url http://[ad_host][ad_port]$url
                 return "filter_return"
             }
         }
         # Normal case: Prepend the root to the URL.
         # 3. set the intended URL
         ad_conn -set url ${root}${ad_conn_url}
 	set ad_conn_url [ad_conn url]

Like [1] this is a problem with host-node maps. The provided patch looks good to me and should not cause harm in cases without host-node maps. The modification introducing this bug was probably too eager.

-g

[1] https://openacs.org/forums/message-view?message_id=4106585