Forum OpenACS Q&A: Response to URL Vars DOUBLE or your Money Back!

Collapse
Posted by David Eison on
I don't know if this problem was ever in OpenACS, but from your description it sounds like it. At least a few versions of ACS used to have a problem where they included vars twice on force-host redirects. Here's my old writeup/fix:

This is a bug in the implementation of ForceHostP in the request processor. Below is the code w/ an explanation of what's wrong and a simple fix (from request-processor-procs.tcl):


                    set query [ns_conn query]
                    if { $query != "" } {
                        set query "?$query"
                        if { [ns_getform] != "" } {
                            set query "$query&[export_entire_form_as_url_vars]"
                        }
                    } elseif { [ns_getform] != "" } { 
                        set query "?[export_entire_form_as_url_vars]"
                    }
                    ad_returnredirect "[ns_conn location][ns_conn url]$query"

First, it gets the query string, and uses it if present. Then, it checks for a form, and uses it if present (in addition to the query string, if that was used). However, getting the form seems to also get query variables, so the query string is found twice. This can easily be fixed by just using the second part:

if { [ns_getform] != "" } { 
    set query "?[export_entire_form_as_url_vars]"
}

www.aolserver.com says ns_getform returns "an ns_set that contains all of the query data that was part of the HTTP request", which would seem to imply that it will always include the query string.