Index: includes/content.node_form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cck/includes/Attic/content.node_form.inc,v
retrieving revision 1.7.2.18
diff -u -p -r1.7.2.18 content.node_form.inc
--- includes/content.node_form.inc	10 Feb 2009 22:53:04 -0000	1.7.2.18
+++ includes/content.node_form.inc	4 May 2009 23:50:55 -0000
@@ -360,8 +360,16 @@ function content_add_more_js($type_name_
   // The new ones didn't exist then, so we need to update Drupal.settings
   // by ourselves in order to let AHAH know about those new form elements.
   $javascript = drupal_add_js(NULL, NULL);
-  $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
 
+  // HACK to make sure that popups originalPath is not overwritten
+  foreach ($javascript['setting'] as $key => $setting) {
+    if (key($setting) == 'popups' && !empty($javascript['setting'][$key]['popups']['originalPath'])) {
+      $javascript['setting'][$key]['popups']['originalPath'] = 'node/add/'. str_replace('_node_form', '', $_POST['form_id']);
+    }
+  }
+
+  $output_js = isset($javascript['setting']) ? '<script type="text/javascript">jQuery.extend(Drupal.settings, '. drupal_to_js(call_user_func_array('array_merge_recursive', $javascript['setting'])) .');</script>' : '';
+  
   $output = theme('status_messages') . drupal_render($field_form) . $output_js;
 
   // Using drupal_json() breaks filefield's file upload, because the jQuery
