View Full Version : Safari and query strings (Beware the Location header!)

08-11-2005, 06:37 PM
I am having some funkiness.

I have a ColdFusion function that returns the name of the current master template and the query string if one is present, all for the purpose of easily supplying a self-reference to forms regardless of their environment.

Well, Safari seems to be appending stuff I didn't ask it to append to my query strings.

Say I have a form with this action:


When I submit the form, it posts back to itself but with the 'action' param value appended with the question mark at the end.


So then, another function expecting a numeric value from #url.software# (url is how to reference the 'GET' scope in CF) chokes and dies when it receives '8?action=software' instead of '8'

Is there some fundamental behavior of Safari that I should be aware of? This does not happen in other browsers. It's not a coding issue. I check the action of the form before I post it, and the source is correct.

08-11-2005, 09:24 PM
This is a most bizarre bug. I thought for a moment that maybe, somehow, some scripting was conflicting with this, that or the other thing and causing the bug, but upon disabling all scripts I still get the bug.

What's weird is Safari is not doing this to all sites with forms posting to actions with query strings. Nonetheless, it and it alone is being affected by this strange bug.

Best I can think at this point is to do some string replacement at page load to make sure query strings don't have extra "?" or name/value pairs.

So weird, though... :confused:

08-11-2005, 10:21 PM
Figured it out...

After the form posts back to the page, some code is run to make the database update. After this I send a location header to redirect the browser to the listing of all items that can be updated. The value I was passing it was simply a query string. It appears that there is then a difference in how Safari handles that header information compared to other browsers. Safari apparently demands a reference to a document in addition to a query string, otherwise it just appends the location value to the current document+query_string, rather than simply appending the location value to the current document, replacing the old query string. As I said, Mozilla, IE and Opera all handle location headers with just a query string with no problems.

Phew! :)

08-11-2005, 11:42 PM
Crisis averted ;)
Thanks for posting the solution too :thumbsup: