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 4 Mar 2006 08:10:10 -0000 @@ -1667,4 +1667,39 @@ $path->dst = urldecode($path->dst); db_query("UPDATE {url_alias} SET dst = '%s', src = '%s' WHERE pid = %d", $path->dst, $path->src, $path->pid); } + return array(); +} + +function system_update_176() { + + function _url_fix($content) { + $urlpattern = "']+))'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 = "']+))'isx"; + preg_match_all($urlpattern, $content, $matches); + + foreach( $matches[2] 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); + } + return array(); }