• could the wp-rss.php, wp-rss2.php and wp-atom.php scripts be changed to the payload sections are contained in CDATA tags by default?
    if my summary includes html (which every post does) the rss feed wont validate unless I add CDATA tags to the scripts.
    wp-rss.php

    <?php
    if (!isset($feed) || !$feed) {
    $blog = 1;
    $doing_rss = 1;
    require('wp-blog-header.php');
    }
    header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
    $more = 1;
    ?>
    <?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
    <!-- generator="wordpress/<?php echo $wp_version ?>" -->
    <rss version="0.92">
    <channel>
    <title><![CDATA[<?php bloginfo_rss('name') ?>]]></title>
    <link><?php bloginfo_rss('url') ?></link>
    <description><![CDATA[<?php bloginfo_rss('description') ?>]]></description>
    <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), 0); ?></lastBuildDate>
    <docs>http://backend.userland.com/rss092</docs>
    <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
    <item>
    <title><![CDATA[<?php the_title_rss() ?>]]></title>
    <?php
    if (get_settings('rss_use_excerpt')) {
    ?>
    <description><![CDATA[<?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?>]]></description>
    <?php
    } else { // use content
    ?>
    <description><![CDATA[<?php the_content_rss('', 0, '', get_settings('rss_excerpt_length')) ?>]]></description>
    <?php
    } // end else use content
    ?>
    <link><?php permalink_single_rss() ?></link>
    </item>
    <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
    </channel>
    </rss>

    wp-rss2.php

    <?php
    if (!isset($feed) || !$feed) {
    $blog = 1;
    $doing_rss = 1;
    require('wp-blog-header.php');
    }
    header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
    $more = 1;
    ?>
    <?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
    <!-- generator="wordpress/<?php echo $wp_version ?>" -->
    <rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    >
    <channel>
    <title><![CDATA[<?php bloginfo_rss('name') ?>]]></title>
    <link><?php bloginfo_rss('url') ?></link>
    <description><![CDATA[<?php bloginfo_rss("description") ?>]]></description>
    <copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate()); ?></copyright>
    <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), 0); ?></pubDate>
    <generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>
    <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
    <item>
    <title><![CDATA[<?php the_title_rss() ?>]]></title>
    <link><?php permalink_single_rss() ?></link>
    <comments><?php comments_link(); ?></comments>
    <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $post->post_date_gmt, 0); ?></pubDate>
    <?php the_category_rss() ?>
    <guid><?php the_permalink($id); ?></guid>
    <?php if (get_settings('rss_use_excerpt')) : ?>
    <description><![CDATA[<?php the_excerpt_rss('', 2) ?>]]></description>
    <?php else : ?>
    <description><![CDATA[<?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?>]]></description>
    <content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>
    <?php endif; ?>
    <wfw:commentRSS><?php echo comments_rss(); ?></wfw:commentRSS>
    </item>
    <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
    </channel>
    </rss>

    wp-atom.php

    <?php
    if (!isset($feed) || !$feed) {
    $blog = 1;
    $doing_rss = 1;
    require('wp-blog-header.php');
    }
    header('Content-type: application/atom+xml; charset=' . get_settings('blog_charset'), true);
    $more = 1;
    ?>
    <?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
    <feed version="0.3"
    xmlns="http://purl.org/atom/ns#"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <title><![CDATA[<?php bloginfo_rss('name') ?>]]></title>
    <link rel="alternate" type="text/html" href="<?php bloginfo_rss('url') ?>" />
    <tagline><![CDATA[<?php bloginfo_rss("description") ?>]]></tagline>
    <modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></modified>
    <copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></copyright>
    <generator url="http://wordpress.org/" version="<?php echo $wp_version ?>">WordPress</generator>
    <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
    <entry>
    <name><?php the_author() ?></name>
    <title><![CDATA[<?php the_title_rss() ?>]]></title>
    <link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />
    <id><?php bloginfo_rss("url") ?>?p=<?php echo $id; ?></id>
    <modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_modified_gmt); ?></modified>
    <issued><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_date_gmt); ?></issued>
    <?php the_category_rss('rdf') ?>
    <summary type="text/html" mode="escaped"><![CDATA[<?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?>]]></summary>
    <?php if (!get_settings('rss_use_excerpt')) { ?>
    <content type="text/html" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
    <?php } ?>
    </entry>
    <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
    </feed>

    I have added more CDATA tags than is strictly necessary, wrapping titles as well as bodys but the feed validates and if somebody wants to have bold tags in there titles (dont ask me why) it should still validate.
    thankyou for reading this far.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter womby

    (@womby)

    that is not rss is it?

    Moderator James Huff

    (@macmanx)

    You’re correct, the link I posted validates your XHTML, which is not RSS. However, XHTML being the core of your site, has an effect on your RSS. As such, if you click that link again, there are still 100 errors coming through. I’m not saying that will fix the problem. It may, but if it doesn’t, it’ll at least make everything look nice and load in all browsers correctly.

    Moderator James Huff

    (@macmanx)

    It seems to be. On a side note, I get a varying number of browser errors when I visit your page as well. Something weird is definitely going on.

    Thread Starter womby

    (@womby)

    my ISP only has a single link to the US, it is currently saturated (has been for 5 days now) and they are not revealing there proposed solution, I am guessing it has something to do with waiting.

    should I assume that I will continue to maintain my own feed scripts?

    Moderator James Huff

    (@macmanx)

    What do you mean?

    Thread Starter womby

    (@womby)

    In my first post I asked if the default feed scripts could be changed to include CDATA tags
    I then pasted in the feed scripts I am using on my blog now.
    If the default feed scripts cannot be changed, I will have to continue to maintain these scripts copying them in every time I update.
    http://mosquito.wordpress.org/bug_view_page.php?bug_id=0000306

    I don’t need any help!
    There was never any problem with MY blog, the feeds work on my server, the problem is the DEFAULT wordpress feed scripts.
    I am ONLY asking if the scripts in the default wordpress distribution can be fixed so I don’t have to keep maintaining my own version.
    I pasted 100% validating wp-rss.php, wp-rss2.php and wp-atom.php scripts, which fix the problem described in the bug report on mosquito (not my bug report).

    this is how crazy this is making me feel, I am not asking for help I am asking for somebody to tell me if there is a reason why the rss, rss2 and atom scripts cannot be fixed.
    here is a diff output shoing how teeny tiny this fix is.

    cp# diff ./wp-rss.php ../techcrazy.theppn.org/wp-rss.php
    17c17
    < <title><?php bloginfo_rss('name') ?></title>
    ---
    > <title><![CDATA[<?php bloginfo_rss('name') ?>]]></title>
    19c19
    < <description><?php bloginfo_rss('description') ?></description>
    ---
    > <description><![CDATA[<?php bloginfo_rss('description') ?>]]></description>
    25c25
    < <title><?php the_title_rss() ?></title>
    ---
    > <title><![CDATA[<?php the_title_rss() ?>]]></title>
    29c29
    < <description><?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?></description>
    ---
    > <description><![CDATA[<?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?>]]></description>
    33c33
    < <description><?php the_content_rss('', 0, '', get_settings('rss_excerpt_length')) ?></description>
    ---
    > <description><![CDATA[<?php the_content_rss('', 0, '', get_settings('rss_excerpt_length')) ?>]]></description>

    Moderator James Huff

    (@macmanx)

    Well, I only tried to do what I could. However, since you “don’t need any help!”, I don’t feel like continuing with this. ‘Tis a sad world where mature gestures are pushed away by immature outbursts.

    The problem I was finding was that even a basic xhtml payload was causing the validator to bork, the two choices were to convert everything to html entities or wrap CDATA around it.
    using CDATA tags seemed more sensible from a processor usage pov.
    Is it possible that the rss content function now encodes the payload rather than just passing it through, and that the textile2-new plugin I use hooks in at the wrong place in the process and breaks it.
    Rather than just asking the question I should go and investigate, back later.
    thankyou.

    Thread Starter womby

    (@womby)

    Upon further investigation.
    The default wordpress rss feeds work fine if there is HTML in the main article body and “Full Text” is selected as the Syndication option. But if html is in the excerpt block and “summary” is selected for the feeds then the feed will not validate.
    The reason full text works and summary doesn’t?
    Full text is wrapped in CDATA tags, while the summary isn’t.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘making rss validate with html payload.’ is closed to new replies.