Anonymous
I’ve been noticing this for a whilemyself. I went into the markdown plugin source and manually registered the_content_rss and the_excerpt_rss, but I was still seeing breakage. I finally determined that the breakage was a result of the “the_excerpt_rss” function trimming the content before markdown had processed it. I moved the apply_filters line just above the trimming code and then ran the output through strip_tags to make sure I didn’t return any open tags. Suddenly everything works again. I haven’t noticed any new breakage as a result of these changes, but I’m sure there has to be a better way.
function the_excerpt_rss($cut = 0, $encode_html = 0) {
$output = get_the_excerpt(true);
$output = convert_chars($output);
if ($cut && !$encode_html) {
$encode_html = 2;
}
if ($encode_html == 1) {
$output = htmlspecialchars($output);
$cut = 0;
} elseif ($encode_html == 0) {
$output = make_url_footnote($output);
} elseif ($encode_html == 2) {
$output = strip_tags($output);
$output = str_replace('&', '&', $output);
}
$output = apply_filters('the_excerpt_rss', $output);
if ($cut) {
$excerpt = '';
$blah = explode(' ', $output);
if (count($blah) > $cut) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
for ($i=0; $i<$k; $i++) {
$excerpt .= $blah[$i].' ';
}
$excerpt .= ($use_dotdotdot) ? '...' : '';
$output = $excerpt;
}
$output = str_replace(']]>', ']]>', $output);
echo strip_tags($output);
}
Having used WP (1.2.1) for two weeks now, I just now noticed this problem (I use Textile 2). Will there be an official fix anytime soon?
I have the same problem on my site. For example, my RSS feed at http://www.rfc1149.net/blog/feed/rss2/ contains:
<description>
I see more and more sites containing ads provided by [Google][] through its [AdSense][] program. Out of curiosity, I went and check their [Online Terms and Conditions][terms] and was stunned by the requirements set out by [Google][].
In no event, however, shall Google make payments for any earned balance less ...
</description>
Only the description and the trackback text seem to be problematic. I have the following in Markdown 1.0.1:
# Add Markdown filter with priority 6 (same as Textile).
add_filter('the_content', 'Markdown', 6);
add_filter('the_content_rss', 'Markdown', 6);
add_filter('the_excerpt', 'Markdown', 6);
add_filter('the_excerpt_rss', 'Markdown', 6);
add_filter('the_excerpt_rss', 'strip_tags', 100);
add_filter('comment_text', 'Markdown', 6);
I added some filters to Textile2 but the resulting feed had HTML entities that made it invalid. Does any one know how to skip entity conversions?
Update: I moved up applyfilter and that seems to solve the problem. The entities remain but are now properly escaped for XML. I think they shouldn’t have been converted in the first place, though, but that’s another story.