Forums

Unfortunately no one can be told what FluxBB is - you have to see it for yourself.

You are not logged in.

#1 2008-06-10 17:59:08

elbekko
Former Developer
From: Leuven, Belgium
Registered: 2008-04-30
Posts: 1,131
Website

Minor syndication remark

Wouldn't it be better if instead of encoding the entities you used CDATA tags in the Atom/RSS feeds? This makes it a bit more compatible with XML parsing tools that don't necessarily recognise HTML entities.


Ben
SVN repository for my extensions - The thread
Quickmarks 0.5
“Question: How does a large software project get to be one year late? Answer: One day at a time!” - Fred Brooks

Offline

#2 2008-06-27 15:45:50

Smartys
Former Developer
Registered: 2008-04-27
Posts: 3,117
Website

Re: Minor syndication remark

Bumped, this also makes sense since it makes the content more easily syndicated.
If we give the content in its most raw format (without htmlencoding it), then the person syndicating the feed can choose how to process it, as opposed to having to work around whatever we have done to it.

Offline

#3 2008-06-27 16:28:08

Reines
Lead developer
From: Scotland
Registered: 2008-05-11
Posts: 3,140
Website

Re: Minor syndication remark

Agreed.

Just make sure a user can't break your feed by posting ]]> tongue

Offline

#4 2008-06-29 20:47:18

Smartys
Former Developer
Registered: 2008-04-27
Posts: 3,117
Website

Re: Minor syndication remark

I'll take advantage of our wonderful and otherwise unused escape_cdata function. tongue

Offline

#5 2008-07-01 01:23:19

Smartys
Former Developer
Registered: 2008-04-27
Posts: 3,117
Website

Re: Minor syndication remark

Index: extern.php
===================================================================
--- extern.php    (revision 320)
+++ extern.php    (working copy)
@@ -129,9 +129,9 @@
     echo '<?xml version="1.0" encoding="utf-8"?>'."\r\n";
     echo '<rss version="2.0">'."\r\n";
     echo "\t".'<channel>'."\r\n";
-    echo "\t\t".'<title>'.forum_htmlencode($feed['title']).'</title>'."\r\n";
+    echo "\t\t".'<title><![CDATA['.escape_cdata($feed['title']).']]></title>'."\r\n";
     echo "\t\t".'<link>'.$feed['link'].'</link>'."\r\n";
-    echo "\t\t".'<description>'.forum_htmlencode($feed['description']).'</description>'."\r\n";
+    echo "\t\t".'<description><![CDATA['.escape_cdata($feed['description']).']]></description>'."\r\n";
     echo "\t\t".'<lastBuildDate>'.gmdate('r', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</lastBuildDate>'."\r\n";
 
     if ($forum_config['o_show_version'] == '1')
@@ -143,10 +143,10 @@
     for ($i = 0; $i < $num_items; ++$i)
     {
         echo "\t\t".'<item>'."\r\n";
-        echo "\t\t\t".'<title>'.forum_htmlencode($feed['items'][$i]['title']).'</title>'."\r\n";
+        echo "\t\t\t".'<title><![CDATA['.escape_cdata($feed['items'][$i]['title']).']]></title>'."\r\n";
         echo "\t\t\t".'<link>'.$feed['items'][$i]['link'].'</link>'."\r\n";
-        echo "\t\t\t".'<description>'.forum_htmlencode($feed['items'][$i]['description']).'</description>'."\r\n";
-        echo "\t\t\t".'<author>dummy@example.com ('.forum_htmlencode($feed['items'][$i]['author']).')</author>'."\r\n";
+        echo "\t\t\t".'<description><![CDATA['.escape_cdata($feed['items'][$i]['description']).']]></description>'."\r\n";
+        echo "\t\t\t".'<author>dummy@example.com (<![CDATA['.escape_cdata($feed['items'][$i]['author']).']]>)</author>'."\r\n";
         echo "\t\t\t".'<pubDate>'.gmdate('r', $feed['items'][$i]['pubdate']).'</pubDate>'."\r\n";
         echo "\t\t\t".'<guid>'.$feed['items'][$i]['link'].'</guid>'."\r\n";
         echo "\t\t".'</item>'."\r\n";
@@ -173,7 +173,7 @@
     echo '<?xml version="1.0" encoding="utf-8"?>'."\r\n";
     echo '<feed xmlns="http://www.w3.org/2005/Atom">'."\r\n";
 
-    echo "\t".'<title type="html">'.forum_htmlencode($feed['title']).'</title>'."\r\n";
+    echo "\t".'<title type="html"><![CDATA['.escape_cdata($feed['title']).']]></title>'."\r\n";
     echo "\t".'<link rel="self" href="'.forum_htmlencode($_SERVER['SCRIPT_NAME'].($_SERVER['QUERY_STRING'] != '' ? '?'.$_SERVER['QUERY_STRING'] :'')).'"/>'."\r\n";
     echo "\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', count($feed['items']) ? $feed['items'][0]['pubdate'] : time()).'</updated>'."\r\n";
 
@@ -190,11 +190,11 @@
     for ($i = 0; $i < $num_items; ++$i)
     {
         echo "\t\t".'<entry>'."\r\n";
-        echo "\t\t\t".'<title type="html">'.forum_htmlencode($feed['items'][$i]['title']).'</title>'."\r\n";
+        echo "\t\t\t".'<title type="html"><![CDATA['.escape_cdata($feed['items'][$i]['title']).']]></title>'."\r\n";
         echo "\t\t\t".'<link rel="alternate" href="'.$feed['items'][$i]['link'].'"/>'."\r\n";
-        echo "\t\t\t".'<'.$content_tag.' type="html">'.forum_htmlencode($feed['items'][$i]['description']).'</'.$content_tag.'>'."\r\n";
+        echo "\t\t\t".'<'.$content_tag.' type="html"><![CDATA['.escape_cdata($feed['items'][$i]['description']).']]></'.$content_tag.'>'."\r\n";
         echo "\t\t\t".'<author>'."\r\n";
-        echo "\t\t\t\t".'<name>'.forum_htmlencode($feed['items'][$i]['author']).'</name>'."\r\n";
+        echo "\t\t\t\t".'<name><![CDATA['.escape_cdata($feed['items'][$i]['author']).']]></name>'."\r\n";
         echo "\t\t\t".'</author>'."\r\n";
         echo "\t\t\t".'<updated>'.gmdate('Y-m-d\TH:i:s\Z', $feed['items'][$i]['pubdate']).'</updated>'."\r\n";
         echo "\t\t\t".'<id>'.$feed['items'][$i]['link'].'</id>'."\r\n";
@@ -229,10 +229,10 @@
     {
         echo "\t".'<'.$forum_tag.' id="'.$feed['items'][$i]['id'].'">'."\r\n";
 
-        echo "\t\t".'<title>'.forum_htmlencode($feed['items'][$i]['title']).'</title>'."\r\n";
+        echo "\t\t".'<title><![CDATA['.escape_cdata($feed['items'][$i]['title']).']]></title>'."\r\n";
         echo "\t\t".'<link>'.$feed['items'][$i]['link'].'</link>'."\r\n";
-        echo "\t\t".'<content>'.forum_htmlencode($feed['items'][$i]['description']).'</content>'."\r\n";
-        echo "\t\t".'<author>'.forum_htmlencode($feed['items'][$i]['author']).'</author>'."\r\n";
+        echo "\t\t".'<content><![CDATA['.escape_cdata($feed['items'][$i]['description']).']]></content>'."\r\n";
+        echo "\t\t".'<author><![CDATA['.escape_cdata($feed['items'][$i]['author']).']]></author>'."\r\n";
         echo "\t\t".'<posted>'.gmdate('r', $feed['items'][$i]['pubdate']).'</posted>'."\r\n";
 
         echo "\t".'</'.$forum_tag.'>'."\r\n";

Look good?

Offline

#6 2008-07-01 13:40:02

elbekko
Former Developer
From: Leuven, Belgium
Registered: 2008-04-30
Posts: 1,131
Website

Re: Minor syndication remark

Guess so, yes.


Ben
SVN repository for my extensions - The thread
Quickmarks 0.5
“Question: How does a large software project get to be one year late? Answer: One day at a time!” - Fred Brooks

Offline

#7 2008-07-13 19:34:59

Smartys
Former Developer
Registered: 2008-04-27
Posts: 3,117
Website

Re: Minor syndication remark

Done in r358

Offline

Board footer

Powered by FluxBB 1.4.8