Commit ccc9276f authored by Dries's avatar Dries

- Patch #4902 by Goba: fix URLs in RSS feeds.
   + Make all channel links absolute.
   + Always set the $base_url as xml:base, thus providing a solid base for
     relative URLs.
parent 8ebedbaa
......@@ -86,7 +86,7 @@ function blog_feed_user($uid = 0) {
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$channel["title"] = $account->name ."'s blog";
$channel["link"] = url("blog/view/$uid");
$channel["link"] = url("blog/view/$uid", NULL, NULL, TRUE);
$channel["description"] = $term->description;
node_feed($result, $channel);
}
......
......@@ -86,7 +86,7 @@ function blog_feed_user($uid = 0) {
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$channel["title"] = $account->name ."'s blog";
$channel["link"] = url("blog/view/$uid");
$channel["link"] = url("blog/view/$uid", NULL, NULL, TRUE);
$channel["description"] = $term->description;
node_feed($result, $channel);
}
......
......@@ -994,8 +994,8 @@ function node_feed($nodes = 0, $channel = array()) {
** A generic function for generating RSS feeds from a set of nodes.
** - $nodes should be an object as returned by db_query() which contains
** the nid field.
** - $channel is an associative array containing title, link, and
** description keys.
** - $channel is an associative array containing title, link,
** description and other keys. The link should be an absolute URL.
*/
if (!$nodes) {
......@@ -1023,7 +1023,7 @@ function node_feed($nodes = 0, $channel = array()) {
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n";
$output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $channel["link"] . "\">\n";
$output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $base_url ."\">\n";
$output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
$output .= "</rss>\n";
......
......@@ -994,8 +994,8 @@ function node_feed($nodes = 0, $channel = array()) {
** A generic function for generating RSS feeds from a set of nodes.
** - $nodes should be an object as returned by db_query() which contains
** the nid field.
** - $channel is an associative array containing title, link, and
** description keys.
** - $channel is an associative array containing title, link,
** description and other keys. The link should be an absolute URL.
*/
if (!$nodes) {
......@@ -1023,7 +1023,7 @@ function node_feed($nodes = 0, $channel = array()) {
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n";
$output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $channel["link"] . "\">\n";
$output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $base_url ."\">\n";
$output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
$output .= "</rss>\n";
......
......@@ -10,7 +10,7 @@ function taxonomy_feed($taxonomy) {
else {
$result = taxonomy_select_nodes($taxonomy, 0);
$term = taxonomy_get_term($taxonomy->tids[0]);
$channel["link"] = url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids");
$channel["link"] = url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids", NULL, NULL, TRUE);
$channel["title"] = variable_get("site_name", "drupal") ." - ". $term->name;
$channel["description"] = $term->description;
node_feed($result, $channel);
......
......@@ -10,7 +10,7 @@ function taxonomy_feed($taxonomy) {
else {
$result = taxonomy_select_nodes($taxonomy, 0);
$term = taxonomy_get_term($taxonomy->tids[0]);
$channel["link"] = url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids");
$channel["link"] = url("taxonomy/view/$taxonomy->operator/$taxonomy->str_tids", NULL, NULL, TRUE);
$channel["title"] = variable_get("site_name", "drupal") ." - ". $term->name;
$channel["description"] = $term->description;
node_feed($result, $channel);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment