--- C:/Documents and Settings/Aldo/Local Settings/Temp/TCVd334.tmp/common.1.687.inc Wed Sep 26 10:36:15 2007 +++ D:/drupal cvs/6.x/drupal/includes/common.inc Wed Sep 26 10:35:50 2007 @@ -880,6 +880,39 @@ return $output; } + /** + * Convert relative URLs in a block of HTML to absolute URLs. + * + * @param $html + * A chunk of HTML. + * @param $base_document + * Optional url to which the chunk of HTML is relative to. + * @return + * The same HTML with URL in <... href=""> and <... src=""> attributes + * changed to absolute. + */ +function drupal_force_absolute_urls($html, $base_document = NULL) { + if(!isset($base_document)) { + global $base_url; + $base_document = $base_url; + } + + $base_document_root = (preg_match('%(\w+://.*?)/%',$base_document, $matches)>0) ? $matches[1] : trim($base_document, '/'); + + $src = '%( href| src)="(?!\w+://)([^/][^"]*)"%'; + $dst = '$1="'. $base_document .'/$2"'; + $data = preg_replace($src, $dst, $html); + + $src = '%( href| src)="(?!\w+://)/?([^"]*)"%'; + $dst = '$1="'. $base_document_root .'/$2"'; + return preg_replace($src, $dst, $html); + + return $data; +} + +/** + + /** * Format a single RSS item. * @@ -889,7 +922,7 @@ $output = "\n"; $output .= ' '. check_plain($title) ."\n"; $output .= ' '. check_url($link) ."\n"; - $output .= ' '. check_plain($description) ."\n"; + $output .= ' '. check_plain(drupal_force_absolute_urls($description, $link)) ."\n"; $output .= format_xml_elements($args); $output .= "\n";