Index: database/updates.inc
===================================================================
RCS file: /cvs/drupal/drupal/database/updates.inc,v
retrieving revision 1.207
diff -u -F^u -r1.207 updates.inc
--- database/updates.inc	3 Mar 2006 08:46:09 -0000	1.207
+++ database/updates.inc	3 Mar 2006 20:23:00 -0000
@@ -1668,3 +1668,36 @@
     db_query("UPDATE {url_alias} SET dst = '%s', src = '%s' WHERE pid = %d", $path->dst, $path->src, $path->pid);
   }
 }
+
+function system_update_176() {
+  
+  function _url_fix($content) {
+    $urlpattern = "'<a\s+href\s*=\s*([\"\'])?(?(1) (.*?)\\1 | ([^\s\>]+))'isx";
+    preg_match_all($urlpattern, $content, $matches);
+    foreach( $matches[1] as $link) {
+      if (!strstr($link, 'mailto:') && !strstr($link, '://') && !strstr($link, '../') && !strstr($link, './') && $link[0] != '/' && $link[0] != '#') {
+        $content = str_replace($link, base_path(). $link, $content);
+      }
+    }
+
+    $matches = '';
+    $urlpattern = "'<img\s+src\s*=\s*([\"\'])?(?(1) (.*?)\\1 | ([^\s\>]+))'isx";
+    preg_match_all($urlpattern, $content, $matches);
+
+    foreach( $matches[1] as $link) {
+      if (!strstr($link, '://') && !strstr($link, '../') && !strstr($link, './') && $link[0] != '/') {
+        $content = str_replace($link, base_path(). $link, $content);
+      }
+    }
+
+    return $content;
+  }
+  
+  $result = db_query('SELECT nid, vid, teaser, body FROM {node_revisions}');  
+  while ($node = db_fetch_object($result)) {
+    $node->teaser = _url_fix($node->teaser);
+    $node->body = _url_fix($node->body);
+
+    db_query('UPDATE {node_revisions} SET body = "%s", teaser = "%s" WHERE nid = %d AND vid = %d', $node->body, $node->teaser, $node->nid, $node->vid);
+  }
+}
