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 19:19:45 -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 = "/]+href=\"([^\"]+)/i"; + preg_match_all($urlpattern, $content, $matches); + foreach( $matches[1] as $link) { + if (!strstr($link, 'mailto:') && !strstr($link, '://') && !strstr($link, '../') && !strstr($link, './') && $link[0] != '/') { + $content = str_replace($link, '/'. $link, $content); + } + } + + $matches = ''; + $urlpattern = "/]+src=\"([^\"]+)/i"; + preg_match_all($urlpattern, $content, $matches); + + foreach( $matches[1] as $link) { + if (!strstr($link, '://') && !strstr($link, '../') && !strstr($link, './') && $link[0] != '/') { + $content = str_replace($link, '/'. $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); + } +}