I have a http_response variant for node_view handler that has a redirect destination with a token querystring:

node/%node:nid?%token:global-thingy

So %token:global-thingy is a valid querystring in some cases and things work fine, but in other cases it's an empty string. This results in a Location header like "http://www.example.com/node/4048%3F".

In page_manager_http_response_render() I was at first not sure why strtr() is used. Why not just set $info['destination'] to $url['path']? Then I realized it's not that simple; $path could have started out as an absolute URL. So, ultimately it's whatever code passes the destination of 'node/nid?' to drupal_get_path_alias() that barfs. Can/should we just remove a trailing empty querystring?

Comments

mstrelan’s picture

It seems to me in D7 that http response code pages can't handle a query string at all for internal URLs. I get the following message

Error
The website encountered an unexpected error. Please try again later.

This is because ctools_context_handler_render_handler() passes $options['query'] to drupal_goto() as a string rather than an array of key to value pairs.

mstrelan’s picture

Title: http response render doesn't handle empty query string » HTTP response render doesn't handle empty query string in D6 or any query string in D7
Version: 6.x-1.8 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new1009 bytes
new530 bytes
new1.32 KB

Three patches attached.

The first is a patch for D7 that fixes the format of query strings (i.e string to array) if they are present and trims empty query strings so the url() function doesn't decode encode the question mark.

The second is for D6 and simply trims empty query strings and finally the third is also for D6 but keeps the format for query strings consistent (ie. an array rather than string).

merlinofchaos’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev

Committed the 7.x version. Leaving this NR for the 6.x version which is unfortunately lower priority for me right now.

  • merlinofchaos committed e7f023b on 8.x-2.x
    Issue #1256878 by mstrelan: Fix format of query strings in http response...

  • merlinofchaos committed e7f023b on 8.x-3.x
    Issue #1256878 by mstrelan: Fix format of query strings in http response...
japerry’s picture

Issue summary: View changes
Status: Needs review » Fixed

D6 version looks good. Fixed!

  • japerry committed 0c3326e on 6.x-1.x authored by mstrelan
    Issue #1256878 by mstrelan: HTTP response render doesn't handle empty...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.