Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.701
diff -u -F^f -r1.701 node.module
--- modules/node/node.module	16 Sep 2006 05:35:57 -0000	1.701
+++ modules/node/node.module	26 Sep 2006 17:44:29 -0000
@@ -658,6 +658,9 @@ function node_view($node, $teaser = FALS
     unset($node->teaser);
   }
 
+  // Allow modules to modify the fully-built node.
+  node_invoke_nodeapi($node, 'alter', $teaser, $page);
+
   return theme('node', $node, $teaser, $page);
 }
 
@@ -715,9 +718,6 @@ function node_build_content($node, $teas
   // Allow modules to make their own additions to the node.
   node_invoke_nodeapi($node, 'view', $teaser, $page);
 
-  // Allow modules to modify the fully-built node.
-  node_invoke_nodeapi($node, 'alter', $teaser, $page);
-
   return $node;
 }
 
Index: modules/upload/upload.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v
retrieving revision 1.132
diff -u -F^f -r1.132 upload.module
--- modules/upload/upload.module	26 Sep 2006 14:11:58 -0000	1.132
+++ modules/upload/upload.module	26 Sep 2006 17:44:29 -0000
@@ -497,30 +497,34 @@ function upload_nodeapi(&$node, $op, $te
               '#weight' => 50,
             );
           }
-          // Manipulate so that inline references work in preview
-          if (!variable_get('clean_url', 0)) {
-            $previews = array();
-            foreach ($node->files as $file) {
-              $file = (object)$file;
-              if (strpos($file->fid, 'upload') !== FALSE) {
-                $previews[] = $file;
-              }
-            }
-            // URLs to files being previewed are actually Drupal paths. When Clean
-            // URLs are disabled, the two do not match. We perform an automatic
-            // replacement from temporary to permanent URLs. That way, the author
-            // can use the final URL in the body before having actually saved (to
-            // place inline images for example).
-            foreach ($previews as $file) {
-              $old = file_create_filename($file->filename, file_create_path());
-              $node->content['#upload_urls'][$old] = url($old);
+        }
+      }
+      break;
+    case 'alter':
+      if (isset($node->files) && user_access('view uploaded files')) {
+        // Manipulate so that inline references work in preview
+        if (!variable_get('clean_url', 0)) {
+          $previews = array();
+          foreach ($node->files as $file) {
+            if (strpos($file['fid'], 'upload') !== FALSE) {
+              $previews[] = $file;
             }
-            $node->content['#after_render'][] = 'upload_fix_preview_urls';
+          }
+
+          // URLs to files being previewed are actually Drupal paths. When Clean
+          // URLs are disabled, the two do not match. We perform an automatic
+          // replacement from temporary to permanent URLs. That way, the author
+          // can use the final URL in the body before having actually saved (to
+          // place inline images for example).
+          foreach ($previews as $file) {
+            $old = file_create_filename($file['filename'], file_create_path());
+            $new = url($old);
+            $node->body = str_replace($old, $new, $node->body);
+            $node->teaser = str_replace($old, $new, $node->teaser);
           }
         }
       }
       break;
-
     case 'insert':
     case 'update':
       if (user_access('upload files')) {
@@ -566,18 +570,6 @@ function upload_nodeapi(&$node, $op, $te
   }
 }
 
-function upload_fix_preview_urls($elements, &$content) {
-  if (is_array($elements['#upload_urls'])) {
-    $old_list = array();
-    $new_list = array();
-    foreach ($elements['#upload_urls'] as $old => $new) {
-      $old_list[] = $old;
-      $new_list[] = $new;
-    }
-    $content = str_replace($old_list, $new_list, $content);
-  }
-}
-
 /**
  * Displays file attachments in table
  */
