From ba1765fbdfeb0fd1fdf1354c1688580ef7864b68 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 28 May 2007 19:43:28 +0000 Subject: [PATCH] * More consistent encoding of titles in rss and atom feeds. Don't use ESCAPE=HTML for titles in the templates for these feeds, and instead escape the title going in to the template. Previously, the title was sometimes double-escaped in a feed (if set via meta title), and sometimes not (if set from the page filename). * In the meta plugin, when a title is set, encode the html entities in it numerically. This works better in the current landscape of a rss spec that doesn't specify encoding, and variously broken feed consumers, according to . --- IkiWiki/Plugin/inline.pm | 4 ++-- IkiWiki/Plugin/meta.pm | 2 +- debian/changelog | 13 +++++++++++-- ...in_Atom__44___RSS_feeds_don__39__t_validate.mdwn | 4 ++++ templates/atomitem.tmpl | 2 +- templates/atompage.tmpl | 2 +- templates/rssitem.tmpl | 4 ++-- templates/rsspage.tmpl | 2 +- 8 files changed, 23 insertions(+), 10 deletions(-) diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 063673730..e23f7b903 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -333,7 +333,7 @@ sub genfeed ($$$$@) { #{{{ my $pcontent = absolute_urls(get_inline_content($p, $page), $url); $itemtemplate->param( - title => pagetitle(basename($p), 1), + title => pagetitle(basename($p)), url => $u, permalink => $u, date_822 => date_822($pagectime{$p}), @@ -377,7 +377,7 @@ sub genfeed ($$$$@) { #{{{ my $template=template($feedtype."page.tmpl", blind_cache => 1); $template->param( - title => $page ne "index" ? pagetitle($page, 1) : $config{wikiname}, + title => $page ne "index" ? pagetitle($page) : $config{wikiname}, wikiname => $config{wikiname}, pageurl => $url, content => $content, diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index 18e28a196..184146cfe 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -65,7 +65,7 @@ sub preprocess (@) { #{{{ } } elsif ($key eq 'title') { - $title{$page}=encode_entities($value); + $title{$page}=HTML::Entities::encode_numeric($value); } elsif ($key eq 'permalink') { $permalink{$page}=$value; diff --git a/debian/changelog b/debian/changelog index 94576d451..ffcb2e85a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,8 +18,17 @@ ikiwiki (2.2) UNRELEASED; urgency=low * Fix FTBFS in test suite introduced in last version. Closes: #425891 * Apply a patch from Carl Worth allowing a class attribute to be passed through the img plugin. Also allow the id attribute to be passed through. - - -- Joey Hess Mon, 28 May 2007 15:00:02 -0400 + * More consistent encoding of titles in rss and atom feeds. Don't use + ESCAPE=HTML for titles in the templates for these feeds, and instead + escape the title going in to the template. Previously, the title was + sometimes double-escaped in a feed (if set via meta title), and sometimes + not (if set from the page filename). + * In the meta plugin, when a title is set, encode the html entities in it + numerically. This works better in the current landscape of a rss spec that + doesn't specify encoding, and variously broken feed consumers, according + to . + + -- Joey Hess Mon, 28 May 2007 15:34:27 -0400 ikiwiki (2.1) unstable; urgency=low diff --git a/doc/bugs/HTML-escaped_titles_in_Atom__44___RSS_feeds_don__39__t_validate.mdwn b/doc/bugs/HTML-escaped_titles_in_Atom__44___RSS_feeds_don__39__t_validate.mdwn index 9d95c15e3..48c168997 100644 --- a/doc/bugs/HTML-escaped_titles_in_Atom__44___RSS_feeds_don__39__t_validate.mdwn +++ b/doc/bugs/HTML-escaped_titles_in_Atom__44___RSS_feeds_don__39__t_validate.mdwn @@ -30,3 +30,7 @@ For Atom, at least, I believe adding `type="xhtml"` to the title element will wo > characters are currently being double-escaped in the rss.) > > --[[Joey]] + +> Update: Ok, I've fixed this for titles, as a special case, but the +> underlying problem remains for other fields in rss feeds (such as +> author), so I'm leaving this bug report open. --[[Joey]] diff --git a/templates/atomitem.tmpl b/templates/atomitem.tmpl index bdbfe69c7..9190fcc84 100644 --- a/templates/atomitem.tmpl +++ b/templates/atomitem.tmpl @@ -1,5 +1,5 @@ - <TMPL_VAR TITLE ESCAPE=HTML> + <TMPL_VAR TITLE> diff --git a/templates/atompage.tmpl b/templates/atompage.tmpl index b811b8764..1bca3e7f8 100644 --- a/templates/atompage.tmpl +++ b/templates/atompage.tmpl @@ -1,7 +1,7 @@ -<TMPL_VAR TITLE ESCAPE=HTML> +<TMPL_VAR TITLE> diff --git a/templates/rssitem.tmpl b/templates/rssitem.tmpl index 0fab42e71..c243b74b3 100644 --- a/templates/rssitem.tmpl +++ b/templates/rssitem.tmpl @@ -1,9 +1,9 @@ - <TMPL_VAR AUTHOR ESCAPE=HTML>: <TMPL_VAR TITLE ESCAPE=HTML> + <TMPL_VAR AUTHOR ESCAPE=HTML>: <TMPL_VAR TITLE> - <TMPL_VAR TITLE ESCAPE=HTML> + <TMPL_VAR TITLE> diff --git a/templates/rsspage.tmpl b/templates/rsspage.tmpl index 38f9b16b3..34c1a33ce 100644 --- a/templates/rsspage.tmpl +++ b/templates/rsspage.tmpl @@ -1,7 +1,7 @@ -<TMPL_VAR TITLE ESCAPE=HTML> +<TMPL_VAR TITLE> -- 2.26.2