=== modified file 'includes/common.inc' --- includes/common.inc 2007-09-12 18:29:31 +0000 +++ includes/common.inc 2007-09-20 22:00:46 +0000 @@ -881,6 +881,30 @@ function format_rss_channel($title, $lin } /** + * Convert relative URLs in a block of HTML to absolute URLs. + * + * @param $html + * A chunk of html. + * @return + * The same HTML with URL in and <... src=""> attributes + * changed to absolute. + */ +function drupal_create_absolute_urls($url) { + global $base_url; + // Relative URLs. + $src = '%( href| src)="(?!\w+://)([^/][^"]*)"%'; + $dst = '$1="'. $base_url .'/$2"'; + $url = preg_replace($src, $dst, $url); + + // URLs that are relative to the root. + $src = '%( href| src)="(?!\w+://)/?([^"]*)"%'; + $dst = '$1="'. $base_url .'/$2"'; + $url = preg_replace($src, $dst, $url); + + return $url; +} + +/** * Format a single RSS item. * * Arbitrary elements may be added using the $args associative array. @@ -889,7 +913,7 @@ function format_rss_item($title, $link, $output = "\n"; $output .= ' '. check_plain($title) ."\n"; $output .= ' '. check_url($link) ."\n"; - $output .= ' '. check_plain($description) ."\n"; + $output .= ' '. check_plain(drupal_create_absolute_urls($description, $link)) ."\n"; $output .= format_xml_elements($args); $output .= "\n";