]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/some_but_not_all_meta_fields_are_stored_escaped.mdwn
response
[ikiwiki.git] / doc / bugs / some_but_not_all_meta_fields_are_stored_escaped.mdwn
1 [[!template id=gitbranch branch=smcv/unescaped-meta author="[[Simon_McVittie|smcv]]"]]
2 [[!tag patch]]
3 (Warning: this branch has not been tested thoroughly.)
4
5 While discussing the [[plugins/meta]] plugin on IRC, Joey pointed out that
6 it stores most meta fields unescaped, but 'title', 'guid' and 'description'
7 are special-cased and stored escaped (with numeric XML/HTML entities). This
8 is to avoid emitting markup in the `<title>` of a HTML page, or in an RSS/Atom
9 feed, neither of which are subject to the [[plugins/htmlscrubber]].
10
11 However, having the meta fields "partially escaped" like this is somewhat
12 error-prone. Joey suggested that perhaps everything should be stored
13 unescaped, and the escaping should be done on output; this branch
14 implements that.
15
16 Points of extra subtlety:
17
18 * The title given to the [[plugins/search]] plugin was previously HTML;
19   now it's plain text, potentially containing markup characters. I suspect
20   that that's what Xapian wants anyway (which is why I didn't change it),
21   but I could be wrong...
22
23   > AFAICS, this if anything, fixes a bug, xapian definitely expects
24   > unescaped text here. --[[Joey]] 
25
26 * Page descriptions in the HTML `<head>` were previously double-escaped:
27   the description was stored escaped with numeric entities, then that was
28   output with a second layer of escaping! In this branch, I just emit
29   the page description escaped once, as was presumably the intention.
30
31 * It's safe to apply this change to a wiki and neglect to rebuild it
32   (assuming I implemented it correctly!), but until the wiki is rebuilt,
33   titles, descriptions and GUIDs for unchanged pages will appear
34   double-escaped on any page that inlines them in `quick=yes` mode, and
35   is rebuilt for some other reason. The failure mode is too much escaping
36   rather than too little, so it shouldn't be a security problem.
37
38 * Reverting this change, if applied, is more dangerous; until the wiki is
39   rebuilt, any titles, descriptions and GUIDs on unchanged pages that
40   contained markup could appear unescaped on any page that inlines them
41   in `quick=yes` mode, and is rebuilt for some other reason. The failure
42   mode here would be too little escaping, i.e. cross-site scripting.
43
44 [[!tag done]]