Index: templates/webform-confirmation.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/templates/webform-confirmation.tpl.php,v
retrieving revision 1.1
diff -u -r1.1 webform-confirmation.tpl.php
--- templates/webform-confirmation.tpl.php	22 May 2009 03:11:18 -0000	1.1
+++ templates/webform-confirmation.tpl.php	11 Feb 2010 22:03:21 -0000
@@ -17,7 +17,13 @@
  */
 ?>
 
-<div class="webform-confirmation"><?php print $confirmation_message ?></div>
+<div class="webform-confirmation">
+  <?php if ($confirmation_message): ?>
+    <?php print $confirmation_message ?>
+  <?php else: ?>
+    <p><?php print t('Thank you, your submission has been received.'); ?></p>
+  <?php endif; ?>
+</div>
 
 <div class="links">
   <a href="<?php print url('node/'. $node->nid) ?>"><?php print t('Go back to the form') ?></a>
Index: webform.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.module,v
retrieving revision 1.180
diff -u -r1.180 webform.module
--- webform.module	10 Feb 2010 05:02:06 -0000	1.180
+++ webform.module	11 Feb 2010 22:03:21 -0000
@@ -25,9 +25,9 @@
       $output = t("<p>This module lets you create forms or questionnaires and define their content. Submissions from these forms are stored in the database and optionally also sent by e-mail to a predefined address.</p>
       <p>Here is how to create one:</p>
       <ul>
-       <li>Go to Create Content and add a webform</li>
+       <li>Go to Create Content and add a webform<./li>
        <li>Add a description to be displayed as a teaser and above the actual form.</li>
-       <li>Add a confirmation message or redirect node that is to be displayed after successful submission.</li>
+       <li>Add a confirmation message and/or redirect node that is to be displayed after successful submission.</li>
        <li>Add one or more components to your form.</li>
        <li>Optionally add an e-mail address to which submissions will be sent. If no email address is specified, no e-mail will be sent when submissions are made through the form.</li>
        <li>Optionally select an e-mail (or hidden) component that will be used to populate the return e-mail address on any sent e-mail.</li>
@@ -797,8 +797,8 @@
 
   module_load_include('inc', 'webform', 'includes/webform.components');
 
-  // Insert the Webform.
-  db_query("INSERT INTO {webform} (nid, confirmation, confirmation_format, teaser, allow_draft, submit_notice, submit_text, submit_limit, submit_interval, additional_validate, additional_submit) VALUES (%d, '%s', %d, %d, %d, %d, '%s', %d, %d, '%s', '%s')", $node->nid, $node->webform['confirmation'], $node->webform['confirmation_format'], $node->webform['teaser'], $node->webform['allow_draft'], $node->webform['submit_notice'], $node->webform['submit_text'], $node->webform['submit_limit'], $node->webform['submit_interval'], $node->webform['additional_validate'], $node->webform['additional_submit']);
+  // Insert the webform.
+  db_query("INSERT INTO {webform} (nid, confirmation, confirmation_format, redirect_url, teaser, allow_draft, submit_notice, submit_text, submit_limit, submit_interval, additional_validate, additional_submit) VALUES (%d, '%s', %d, '%s', %d, %d, %d, '%s', %d, %d, '%s', '%s')", $node->nid, $node->webform['confirmation'], $node->webform['confirmation_format'], $node->webform['redirect_url'], $node->webform['teaser'], $node->webform['allow_draft'], $node->webform['submit_notice'], $node->webform['submit_text'], $node->webform['submit_limit'], $node->webform['submit_interval'], $node->webform['additional_validate'], $node->webform['additional_submit']);
 
   // Insert the components into the database. Used with clone.module.
   if (isset($node->webform['components']) && !empty($node->webform['components'])) {
@@ -888,6 +888,7 @@
     $additions['webform'] = array(
       'confirmation' => '',
       'confirmation_format' => FILTER_FORMAT_DEFAULT,
+      'redirect_url' => '',
       'teaser' => 0,
       'allow_draft' => 0,
       'submit_notice' => 0,
@@ -1826,32 +1827,41 @@
     watchdog('webform', 'Submission posted to %title. <a href="!url">Results</a>. !details', array('%title' => $node->title, '!url' => url('node/'. $node->nid .'/submission/'. $sid), '!results' => "<br />\n<pre>". htmlentities(print_r($form_state['values'], TRUE)) .'</pre>'));
   }
 
-  // Check confirmation field to see if redirect should be to another node or a message.
+  // Strip out empty tags added by WYSIWYG editors if needed.
+  $confirmation = strlen(trim(strip_tags($node->webform['confirmation']))) ? $node->webform['confirmation'] : '';
+  $redirect_url = trim($node->webform['redirect_url']);
+
+  // Check confirmation and redirect_url fields.
+  $message = NULL;
   if ($is_draft) {
-    drupal_set_message(t('Draft saved.'));
     $redirect = NULL;
+    $message = t('Draft saved');
   }
   elseif (isset($form_state['values']['submission'])) {
-    drupal_set_message(t('Submission updated.'));
     $redirect = NULL;
+    $message = t('Submission updated.');
   }
-  elseif (valid_url(trim($node->webform['confirmation']), TRUE)) {
-    $redirect = trim($node->webform['confirmation']);
+  elseif (valid_url($redirect_url, TRUE)) {
+    $redirect = $redirect_url;
+   }
+  elseif ($redirect_url && strpos($redirect_url, 'http') !== 0) {
+    $parts = parse_url($redirect_url);
+    $query = $parts['query'] ? ($parts['query'] . '&sid=' . $sid) : ('sid=' . $sid);
+    $redirect = array($parts['path'], $query, $parts['fragment']);
   }
-  // Check if the form should redirect to an internal URL, strip tags off
-  // first in case a WYSIWYG editor messed it up.
-  elseif (preg_match('/^internal:/', trim(strip_tags($node->webform['confirmation'])))) {
-    $path = preg_replace('/^internal:/', '', trim(strip_tags($node->webform['confirmation'])));
-    $redirect = array(trim($path), 'sid='. $sid);
+  else {
+    $redirect = array('node/' . $node->nid . '/done', 'sid=' . $sid);
   }
-  elseif (preg_match('/^message:/', $node->webform['confirmation'])) {
-    $message = preg_replace('/^message:/', '', $node->webform['confirmation']);
+
+  // Show a message if manually set.
+  if (isset($message)) {
     drupal_set_message($message);
-    $redirect = NULL;
   }
-  else {
-    $redirect = array('node/'. $node->nid .'/done', 'sid='. $sid);
+  // If redirecting and we have a confirmation message, show it as a message.
+  elseif (!empty($redirect) && !empty($confirmation)) {
+    drupal_set_message(check_markup($confirmation, $node->webform['confirmation_format'], FALSE));
   }
+
   $form_state['redirect'] = $redirect;
 }
 
@@ -1939,12 +1949,9 @@
  * Prepare for theming of the webform submission confirmation.
  */
 function template_preprocess_webform_confirmation(&$vars) {
-  if (empty($vars['node']->webform['confirmation'])) {
-    drupal_set_message(t('Thank you, your submission has been received.'));
-    drupal_goto('node/'. $vars['node']->nid);
-  }
-
-  $vars['confirmation_message'] = check_markup($vars['node']->webform['confirmation'], $vars['node']->webform['confirmation_format'], FALSE);
+  // Strip out empty tags added by WYSIWYG editors if needed.
+  $confirmation = strlen(trim(strip_tags($vars['node']->webform['confirmation']))) ? $vars['node']->webform['confirmation'] : '';
+  $vars['confirmation_message'] = check_markup($confirmation, $vars['node']->webform['confirmation_format'], FALSE);
 }
 
 /**
Index: webform.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/webform.install,v
retrieving revision 1.37
diff -u -r1.37 webform.install
--- webform.install	10 Feb 2010 05:13:42 -0000	1.37
+++ webform.install	11 Feb 2010 22:03:20 -0000
@@ -32,6 +32,11 @@
         'not null' => TRUE,
         'default' => 0,
       ),
+      'redirect_url' => array(
+        'description' => 'The URL a user is redirected to after submitting a form.',
+        'type' => 'varchar',
+        'length' => 255,
+      ),
       'teaser' => array(
         'description' => 'Boolean value for whether the entire form should be displayed on the teaser.',
         'type' => 'int',
@@ -858,6 +863,40 @@
 }
 
 /**
+ * Add the redirect_url field and update existing webforms to use it.
+ */
+function webform_update_6310() {
+  $ret = array();
+
+  // Safety check to prevent re-adding existing column.
+  if (db_column_exists('webform', 'redirect_url')) {
+    return $ret;
+  }
+
+  // Add the new redirect_url column.
+  db_add_field($ret, 'webform', 'redirect_url', array('type' => 'varchar', 'length' => '255'));
+
+  // If the webform is using the confirmation field as a redirect then move it
+  // to the new redirect_url field.
+  $result = db_query("SELECT nid, confirmation FROM {webform}");
+  while ($row = db_fetch_object($result)) {
+    $confirmation = trim(strip_tags($row->confirmation));
+    if (valid_url($confirmation, TRUE) || preg_match('/^internal:/', $confirmation)) {
+      $redirect_url = preg_replace('/^internal:/', '', $confirmation);
+      db_query("UPDATE {webform} SET redirect_url = '%s' WHERE nid = %d", $redirect_url, $row->nid);
+      db_query("UPDATE {webform} SET confirmation = '' WHERE nid = %d", '', $row->nid);
+    }
+    elseif (preg_match('/^message:/', $confirmation)) {
+      $message = preg_replace('/^message:/', '', $confirmation);
+      db_query("UPDATE {webform} SET redirect_url = '%s' WHERE nid = %d", 'node/' . $row->nid, $row->nid);
+      db_query("UPDATE {webform} SET confirmation = '%s' WHERE nid = %d", $message, $row->nid);
+    }
+  }
+
+  return $ret;
+}
+
+/**
  * Recursively delete all files and folders in the specified filepath, then
  * delete the containing folder.
  *
Index: includes/webform.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/webform/includes/webform.pages.inc,v
retrieving revision 1.9
diff -u -r1.9 webform.pages.inc
--- includes/webform.pages.inc	10 Feb 2010 01:05:36 -0000	1.9
+++ includes/webform.pages.inc	11 Feb 2010 22:03:21 -0000
@@ -29,8 +29,8 @@
 
   $form['submission']['confirmation_wrapper']['confirmation'] = array(
     '#type' => 'textarea',
-    '#title' => t('Confirmation message or redirect URL'),
-    '#description' => t('Message to be shown upon successful submission or a path to a redirect page. Preface message with <em>message:</em> for a simple message that does not require a page refresh. Redirect pages must start with <em>http://</em> for external sites or <em>internal:</em> for an internal path. i.e. <em>http://www.example.com</em> or <em>internal:node/10</em>'),
+    '#title' => t('Confirmation message'),
+    '#description' => t('Message to be shown upon successful submission. If <em>Redirect URL</em> is set this displays as a message, otherwise it will be shown on its own page.'),
     '#default_value' => $node->webform['confirmation'],
     '#cols' => 40,
     '#rows' => 10,
@@ -38,6 +38,15 @@
 
   $form['submission']['confirmation_wrapper']['format'] = filter_form($node->webform['confirmation_format'], NULL, array('confirmation_format'));
 
+  // Redirect URL.
+  $form['submission']['redirect_url'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Redirect URL'),
+    '#description' => t('URL to redirect the user to upon successful submission.'),
+    '#default_value' => $node->webform['redirect_url'],
+    '#maxlength' => 255,
+  );
+
   // Submission limit settings.
   $form['submission']['submit_limit'] = array(
     '#type' => 'item',
@@ -180,11 +189,20 @@
     $emails = explode(',', $form_state['values']['email']);
     foreach ($emails as $email) {
       if (!valid_email_address(trim($email))) {
-        form_set_error('email', t('The entered email address %address is not a valid address.', array('%address' => $email)));
+        form_error($form['submission']['redirect_url'], t('The entered email address %address is not a valid address.', array('%address' => $email)));
         break;
       }
     }
   }
+
+  // Ensure the entered redirect URL is valid.
+  $redirect_url = trim($form_state['values']['redirect_url']);
+  if (!empty($redirect_url) && strpos($redirect_url, 'http') === 0 && !valid_url($redirect_url, TRUE)) {
+    form_error($form['submission']['redirect_url'], t('The entered URL is not a valid address.'));
+  }
+  else {
+    form_set_value($form['submission']['redirect_url'], $redirect_url, $form_state);
+  }
 }
 
 /**
@@ -197,6 +215,9 @@
   $node->webform['confirmation'] = $form_state['values']['confirmation'];
   $node->webform['confirmation_format'] = $form_state['values']['confirmation_format'];
 
+  // Save the redirect URL
+  $node->webform['redirect_url'] = $form_state['values']['redirect_url'];
+
   // Save roles.
   $node->webform['roles'] = array_keys(array_filter($form_state['values']['roles']));
 
@@ -227,6 +248,8 @@
   $node->webform['additional_submit'] = $form_state['values']['additional_submit'];
 
   node_save($node);
+
+  drupal_set_message(t('The form settings have been updated.'));
 }
 
 /**
