diff options
author | Russ Allbery <eagle@eyrie.org> | 2010-10-12 23:19:48 +0000 |
---|---|---|
committer | Russ Allbery <eagle@eyrie.org> | 2010-10-12 23:19:48 +0000 |
commit | 6b584e79d7f8e7eabe59653db60330d1b1c6fb40 (patch) | |
tree | 0829b7b4f27873b2a1ab0966a204c6bc03ee28b1 /bin | |
parent | 1ec9b73f28d3ead2ba8885037708f1327752c57c (diff) |
Always surround the description data for each entry with CDATA, and in the
case of paragraphs generated directly from a description in an .rss file,
also wrap them in <p> to create a valid HTML fragment.
Previously, descriptions taken directly from .rss were reproduced without
change or further HTML wrapping in the RSS file, which caused problems if
they contained escaped HTML tags like <body>.
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/spin-rss | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/bin/spin-rss b/bin/spin-rss index 2aa20af..893d3fe 100755 --- a/bin/spin-rss +++ b/bin/spin-rss @@ -168,7 +168,7 @@ sub rss_journal { pop @page; pop @page; pop @page while (@page and $page[$#page] =~ /^\s*$/); - return '<![CDATA[' . join ('', @page) . "]]>\n"; + return join ('', @page) . "\n"; } # Format a review into HTML for inclusion in an RSS feed. Takes the path to @@ -214,7 +214,7 @@ sub rss_review { $page =~ s{<span class="story"><span id="\S+">(.*?)</span></span>} {<strong>$1</strong>}sg; $page = "<p>Review: <cite>$title</cite>, $author</p>\n\n" . $page; - return '<![CDATA[' . $page . "]]>\n"; + return $page . "\n"; } # Print out the RSS version of the changes information given a file to which @@ -259,6 +259,8 @@ EOC if ($entry->{description}) { $description = xml_escape ($entry->{description}); $description =~ s/^/ /mg; + $description =~ s,^(\s*),$1<p>,; + $description =~ s,\n*\z,</p>\n,; } elsif ($entry->{journal}) { $description = rss_journal ($entry->{journal}); } elsif ($entry->{review}) { @@ -270,9 +272,9 @@ EOC print $file " <item>\n"; print $file " <title>$title</title>\n"; print $file " <link>$entry->{link}</link>\n"; - print $file " <description>\n"; + print $file " <description><![CDATA[\n"; print $file "$description"; - print $file " </description>\n"; + print $file " ]]></description>\n"; print $file " <pubDate>$date</pubDate>\n"; print $file " <guid$perma>$entry->{guid}</guid>\n"; print $file " </item>\n"; |