Index: database/updates.inc
===================================================================
RCS file: /cvs/drupal/drupal/database/updates.inc,v
retrieving revision 1.209
diff -u -F^u -r1.209 updates.inc
--- database/updates.inc	4 Mar 2006 18:12:10 -0000	1.209
+++ database/updates.inc	4 Mar 2006 20:13:30 -0000
@@ -1674,3 +1674,31 @@
   $ret[] = update_sql('ALTER TABLE {filter_formats} ADD UNIQUE KEY (name)');
   return $ret;
 }
+
+function system_update_177() {
+  function _url_fix($content) {
+    $urlpattern[] = "'<a\s+href\s*=\s*([\"\'])?(?(1) (.*?)\\1 | ([^\s\>]+))'isx";
+    $urlpattern[] = "'<img\s+src\s*=\s*([\"\'])?(?(1) (.*?)\\1 | ([^\s\>]+))'isx";
+
+    foreach ($urlpattern as $pattern) {
+      $matches = '';
+      preg_match_all($pattern, $content, $matches);
+      foreach($matches[2] as $url) {
+        if ($url != '' && !strstr($url, 'mailto:') && !strstr($url, '://') && !strstr($url, '../') && !strstr($url, './') && $url[0] != '/' && $url[0] != '#') {
+          $content = str_replace($url, base_path(). $url, $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);
+  }
+  
+  return array();  
+}
