Here's the code:

function webform_replace_url_tokens($redirect_url, $node = NULL, $submission = NULL) {
  // Parse the url into its components.
  $parsed_redirect_url = drupal_parse_url($redirect_url);
  // Replace tokens in each component.
  $parsed_redirect_url['path'] = webform_replace_tokens($parsed_redirect_url['path'], $node, $submission);
  if (!empty($parsed_redirect_url['query'])) {
    foreach ($parsed_redirect_url['query'] as $key => $value) {
      $parsed_redirect_url['query'][$key] = trim(webform_replace_tokens($value, $node, $submission));
    }
  }
...

As you see, this code always expects $value to have the string type. However, it can be an array (of arrays) of strings. For example, if the redirect url is something like this:

fillpdf?fid=23&webform[nid]=value1&webform[sid]=value2

This can be tested by setting the "Redirection location" field to "Custom URL" on page node/*/webform/configure and the custom url value to the string above. This will produce the following errors on submitting the form:

Warning: trim() expects parameter 1 to be string, array given in webform_replace_tokens() (line 3855 of sites/all/modules/contrib/webform/webform.module).
Warning: trim() expects parameter 1 to be string, array given in webform_replace_url_tokens() (line 3940 of sites/all/modules/contrib/webform/webform.module).

Issue fork webform-2637520

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TonyK created an issue. See original summary.

wizonesolutions’s picture

Version: 7.x-4.12 » 7.x-4.19

This is still an issue in 7.x-4.19.

Liam Morland’s picture

Version: 7.x-4.19 » 7.x-4.x-dev
Issue summary: View changes
Liam Morland’s picture

This patch makes webform_replace_url_tokens() recursively handle arrays as input. I would appreciate a second set of eyes reviewing this code.

wizonesolutions’s picture

This code looks fine to me, and it's been some time. Queued up some re-tests, consider it +1 from me if tests pass.