(Please CC) ikiwiki has accumulated several bugfixes throughout July and August, all of which have been tested in the versions in unstable. Many of these fixes were made well before the freeze, but did not transition to testing due to other changes.
Before the most recent d-d-a post, I prepared a release that backports all these bug fixes. Changlog looks like this: ikiwiki (2.53.1) UNRELEASED; urgency=low * Backported all relevant bug fixes from mainline to debian testing. * ikiwiki-transition: Fix command-line processing so the prefix_directives transition works again. * Fixes creation of pages when clicking on WikiLinks starting with "/". * Change deb dependencies to list Text::Markdown before markdown, since the former, while slower, has a much better html parser that avoids numerous bugs. * smileys: Some fixes for escaped smileys. * smileys: Note that smileys need to be double-escaped for the escaping to work. Markdown removes one level of escaping. * Add a postscan hook. * search: Use postscan hook, avoid updating index when previewing. * search: Fixes for title stemming, and use better term for tags. (Gabriel McManus) (Rebuilding the wiki on upgrade to this version is recommended if you use the search plugin.) * meta: fix title() PageSpec (DOS). Closes: #497444 * Really fix bug with links to pages with names containing colons. Previous fix mised a few cases. * toggle: Fix incompatability between javascript and webkit. * toggle: Fix for when html got tidied. Closes: #492529 (Enrico Zini) * inline: Ignore parent dirs when sorting pages by title. * external: Fix support for hooks called in an array context. * edittemplate: Don't wipe out edits on preview. * map: The fix for #449285 was buggy and broke display of parents in certian circumstances. * Work around perl $_ scoping nonsense that caused breakage when loading external plugins. Of these, #497444 is unambiguously RC; the edittemplate fix could also be argued to lose data, in some circumstances; and the search postscan fix could be used to maliciously corrupt/add/remove data from the search index. Would a t-p-u upload of the above be ok, or should I give up getting most of these bugs fixed and only upload for the more serious ones? Attached is a patch fixing all of the above. -- see shy jo
diff --git a/IkiWiki.pm b/IkiWiki.pm index 5a05a0f..ea44081 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -151,7 +151,9 @@ sub loadplugins () { #{{{ unshift @INC, possibly_foolish_untaint($config{libdir}); } - loadplugin($_) foreach @{$config{plugin}}; + foreach my $plugin (@{$config{plugin}}) { + loadplugin($plugin); + } run_hooks(getopt => sub { shift->() }); if (grep /^-/, @ARGV) { @@ -541,17 +543,18 @@ sub beautify_url ($) { #{{{ # Ensure url is not an empty link, and # if it's relative, make that explicit to avoid colon confusion. - if ($url !~ /\//) { + if ($url !~ /^\//) { $url="./$url"; } return $url; } #}}} -sub urlto ($$) { #{{{ +sub urlto ($$;$) { #{{{ my $to=shift; my $from=shift; - + my $absolute=shift; + if (! length $to) { return beautify_url(baseurl($from)."index.$config{htmlext}"); } @@ -560,6 +563,10 @@ sub urlto ($$) { #{{{ $to=htmlpage($to); } + if ($absolute) { + return $config{url}.beautify_urlpath("/".$to); + } + my $link = abs2rel($to, dirname(htmlpage($from))); return beautify_url($link); @@ -718,6 +725,8 @@ sub preprocess ($$$;$$) { #{{{ my $prefix=shift; my $command=shift; my $params=shift; + $params="" if ! defined $params; + if (length $escape) { return "[[$prefix$command $params]]"; } diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 99cead6..b1a526a 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -304,8 +304,9 @@ sub cgi_editpage ($$) { #{{{ # This untaint is safe because we check file_pruned. my $page=$form->field('page'); $page=possibly_foolish_untaint($page); + my $absolute=($page =~ s#^/+##); if (! defined $page || ! length $page || - file_pruned($page, $config{srcdir}) || $page=~/^\//) { + file_pruned($page, $config{srcdir})) { error("bad page name"); } @@ -424,7 +425,8 @@ sub cgi_editpage ($$) { #{{{ if (! defined $from || ! length $from || $from ne $form->field('from') || file_pruned($from, $config{srcdir}) || - $from=~/^\// || + $from=~/^\// || + $absolute || $form->submitted eq "Preview") { @page_locs=$best_loc=$page; } diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm index 76c1cd4..3d31fd8 100644 --- a/IkiWiki/Plugin/edittemplate.pm +++ b/IkiWiki/Plugin/edittemplate.pm @@ -54,7 +54,9 @@ sub formbuilder (@) { #{{{ my [EMAIL PROTECTED]; my $form=$params{form}; - return if $form->field("do") ne "create"; + return if $form->field("do") ne "create" || + length $form->field("editcontent"); + my $page=$form->field("page"); # The tricky bit here is that $page is probably just the base diff --git a/IkiWiki/Plugin/external.pm b/IkiWiki/Plugin/external.pm index 204442c..1abf0d4 100644 --- a/IkiWiki/Plugin/external.pm +++ b/IkiWiki/Plugin/external.pm @@ -217,8 +217,7 @@ sub hook ($@) { #{{{ delete $params{call}; IkiWiki::hook(%params, call => sub { - my $ret=IkiWiki::Plugin::external::rpc_call($plugin, $callback, @_); - return $ret; + IkiWiki::Plugin::external::rpc_call($plugin, $callback, @_); }); } #}}} diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 8890e5e..2faaa57 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -142,7 +142,7 @@ sub preprocess_inline (@) { #{{{ } if (exists $params{sort} && $params{sort} eq 'title') { - @list=sort @list; + @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list; } elsif (exists $params{sort} && $params{sort} eq 'mtime') { @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list; @@ -423,13 +423,13 @@ sub genfeed ($$$$@) { #{{{ my $page=shift; my @[EMAIL PROTECTED]; - my $url=URI->new(encode_utf8($config{url}."/".urlto($page,""))); + my $url=URI->new(encode_utf8(urlto($page,"",1))); my $itemtemplate=template($feedtype."item.tmpl", blind_cache => 1); my $content=""; my $lasttime = 0; foreach my $p (@pages) { - my $u=URI->new(encode_utf8($config{url}."/".urlto($p, ""))); + my $u=URI->new(encode_utf8(urlto($p, "", 1))); my $pcontent = absolute_urls(get_inline_content($p, $page), $url); $itemtemplate->param( @@ -519,7 +519,7 @@ sub pingurl (@) { #{{{ foreach my $page (keys %toping) { my $title=pagetitle(basename($page), 0); - my $url="$config{url}/".urlto($page, ""); + my $url=urlto($page, "", 1); foreach my $pingurl (@{$config{pingurl}}) { debug("Pinging $pingurl for $page"); eval { diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 5b6a843..1a32049 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -71,7 +71,7 @@ sub preprocess (@) { #{{{ my $parent=""; my $indent=0; my $openli=0; - my $dummy=0; + my $addparent=""; my $map = "<div class='map'>\n<ul>\n"; foreach my $item (sort keys %mapitems) { my @linktext = (length $mapitems{$item} ? (linktext => $mapitems{$item}) : ()); @@ -81,14 +81,14 @@ sub preprocess (@) { #{{{ my $baseitem=IkiWiki::dirname($item); while (length $parent && length $baseitem && $baseitem !~ /^\Q$parent\E(\/|$)/) { $parent=IkiWiki::dirname($parent); - last if !$dummy && length $parent && $baseitem =~ /^\Q$parent\E(\/|$)/; + last if length $addparent && $baseitem =~ /^\Q$addparent\E(\/|$)/; + $addparent=""; $indent--; $map .= "</li>\n"; if ($indent > 0) { $map .= "</ul>\n"; } } - $dummy=0; while ($depth < $indent) { $indent--; $map .= "</li>\n"; @@ -105,11 +105,12 @@ sub preprocess (@) { #{{{ $map .= "<ul>\n"; } if ($depth > $indent) { - $dummy=1; $p.="/".shift(@bits); + $addparent=$p; + $addparent=~s/^\///; $map .= "<li>" .htmllink($params{page}, $params{destpage}, - $p, class => "mapparent", + "/".$common_prefix.$p, class => "mapparent", noimageinline => 1) ."\n"; $openli=1; diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index 671060f..5c1827c 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -260,7 +260,7 @@ sub match { #{{{ $val=$pagestate{$page}{meta}{$field}; } elsif ($field eq 'title') { - $val=pagetitle($page); + $val = IkiWiki::pagetitle($page); } if (defined $val) { diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm index 284f477..eedfa69 100644 --- a/IkiWiki/Plugin/search.pm +++ b/IkiWiki/Plugin/search.pm @@ -9,7 +9,7 @@ use IkiWiki 2.00; sub import { #{{{ hook(type => "checkconfig", id => "search", call => \&checkconfig); hook(type => "pagetemplate", id => "search", call => \&pagetemplate); - hook(type => "sanitize", id => "search", call => \&index); + hook(type => "postscan", id => "search", call => \&index); hook(type => "delete", id => "search", call => \&delete); hook(type => "cgi", id => "search", call => \&cgi); } # }}} @@ -48,8 +48,6 @@ my $scrubber; my $stemmer; sub index (@) { #{{{ my [EMAIL PROTECTED]; - - return $params{content} if $IkiWiki::preprocessing{$params{destpage}}; setupfiles(); @@ -125,15 +123,13 @@ sub index (@) { #{{{ $tg->index_text($caption, 2); $tg->index_text($title, 2) if $title ne $caption; $tg->index_text($toindex); - $tg->index_text(lc($title), 1, "ZS"); # for title:foo + $tg->index_text(lc($title), 1, "S"); # for title:foo foreach my $link (@{$links{$params{page}}}) { - $tg->index_text(lc($link), 1, "ZLINK"); # for link:bar + $tg->index_text(lc($link), 1, "XLINK"); # for link:bar } $doc->add_term($pageterm); $db->replace_document_by_term($pageterm, $doc); - - return $params{content}; } #}}} sub delete (@) { #{{{ diff --git a/IkiWiki/Plugin/skeleton.pm b/IkiWiki/Plugin/skeleton.pm index 17a2162..1af8e4e 100644 --- a/IkiWiki/Plugin/skeleton.pm +++ b/IkiWiki/Plugin/skeleton.pm @@ -18,6 +18,7 @@ sub import { #{{{ hook(type => "scan", id => "skeleton", call => \&scan); hook(type => "htmlize", id => "skeleton", call => \&htmlize); hook(type => "sanitize", id => "skeleton", call => \&sanitize); + hook(type => "postscan", id => "skeleton", call => \&postscan); hook(type => "format", id => "skeleton", call => \&format); hook(type => "pagetemplate", id => "skeleton", call => \&pagetemplate); hook(type => "templatefile", id => "skeleton", call => \&templatefile); @@ -89,6 +90,12 @@ sub sanitize (@) { #{{{ return $params{content}; } # }}} +sub postscan (@) { #{{{ + my [EMAIL PROTECTED]; + + debug("skeleton plugin running as postscan"); +} # }}} + sub format (@) { #{{{ my [EMAIL PROTECTED]; diff --git a/IkiWiki/Plugin/smiley.pm b/IkiWiki/Plugin/smiley.pm index 51b32b2..747cab3 100644 --- a/IkiWiki/Plugin/smiley.pm +++ b/IkiWiki/Plugin/smiley.pm @@ -15,7 +15,7 @@ sub import { #{{{ sub build_regexp () { #{{{ my $list=readfile(srcfile("smileys.mdwn")); - while ($list =~ m/^\s*\*\s+\\([^\s]+)\s+\[\[([^]]+)\]\]/mg) { + while ($list =~ m/^\s*\*\s+\\\\([^\s]+)\s+\[\[([^]]+)\]\]/mg) { my $smiley=$1; my $file=$2; @@ -48,7 +48,7 @@ sub sanitize (@) { #{{{ $_=$params{content}; return $_ unless length $smiley_regexp; - + MATCH: while (m{(?:^|(?<=\s|>))(\\?)$smiley_regexp(?:(?=\s|<)|$)}g) { my $escape=$1; my $smiley=$2; @@ -68,16 +68,18 @@ MATCH: while (m{(?:^|(?<=\s|>))(\\?)$smiley_regexp(?:(?=\s|<)|$)}g) { # Reset pos back to where it was before this test. pos=$pos; } - + if ($escape) { # Remove escape. substr($_, $epos, 1)=""; + pos=$epos+1; } else { # Replace the smiley with its expanded value. substr($_, $spos, length($smiley))= htmllink($params{page}, $params{destpage}, $smileys{$smiley}, linktext => $smiley); + pos=$epos+1; } } diff --git a/IkiWiki/Plugin/toggle.pm b/IkiWiki/Plugin/toggle.pm index 284eb82..825b55d 100644 --- a/IkiWiki/Plugin/toggle.pm +++ b/IkiWiki/Plugin/toggle.pm @@ -39,9 +39,9 @@ function toggle(s) { style.display = "none"; } -function getElementsByClass(class) { +function getElementsByClass(c) { var ret = new Array(); - var pattern = new RegExp("(^|\\s)"+class+"(\\s|$)"); + var pattern = new RegExp("(^|\\s)"+c+"(\\s|$)"); var els = document.getElementsByTagName('*'); for (i = 0, j = 0; i < els.length; i++) { if ( pattern.test(els[i].className) ) { @@ -106,7 +106,7 @@ sub preprocess_toggleable (@) { #{{{ sub format (@) { #{{{ my [EMAIL PROTECTED]; - if ($params{content}=~s!(<div class="toggleable(?:-open)?" id="[^"]+">)</div>!$1!g) { + if ($params{content}=~s!(<div class="toggleable(?:-open)?" id="[^"]+">\s*)</div>!$1!g) { $params{content}=~s/<div class="toggleableend">//g; if (! ($params{content}=~s!^<body>!<body>$javascript!m)) { # no </body> tag, probably in preview mode diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index c241fd4..e76dcef 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -135,6 +135,10 @@ sub genpage ($$) { #{{{ }); $content=$template->output; + + run_hooks(postscan => sub { + shift->(page => $page, content => $content); + }); run_hooks(format => sub { $content=shift->( diff --git a/debian/changelog b/debian/changelog index adfa2c2..1b892da 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,34 @@ +ikiwiki (2.53.1) UNRELEASED; urgency=low + + * ikiwiki-transition: Fix command-line processing so the prefix_directives + transition works again. + * Fixes creation of pages when clicking on WikiLinks starting with "/". + * Change deb dependencies to list Text::Markdown before markdown, since + the former, while slower, has a much better html parser that avoids + numerous bugs. + * smileys: Some fixes for escaped smileys. + * smileys: Note that smileys need to be double-escaped for the escaping to + work. Markdown removes one level of escaping. + * Add a postscan hook. + * search: Use postscan hook, avoid updating index when previewing. + * search: Fixes for title stemming, and use better term for tags. (Gabriel McManus) + (Rebuilding the wiki on upgrade to this version is recommended if you use the + search plugin.) + * meta: fix title() PageSpec + * Really fix bug with links to pages with names containing colons. + Previous fix mised a few cases. + * toggle: Fix incompatability between javascript and webkit. + * toggle: Fix for when html got tidied. Closes: #492529 (Enrico Zini) + * inline: Ignore parent dirs when sorting pages by title. + * external: Fix support for hooks called in an array context. + * edittemplate: Don't wipe out edits on preview. + * map: The fix for #449285 was buggy and broke display of parents in certian + circumstances. + * Work around perl $_ scoping nonsense that caused breakage when loading + external plugins. + + -- Josh Triplett <[EMAIL PROTECTED]> Wed, 09 Jul 2008 21:30:33 -0700 + ikiwiki (2.53) unstable; urgency=low * search: generate configuration files once only when rebuilding diff --git a/debian/control b/debian/control index b29d5ff..a50c13c 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: ikiwiki Section: web Priority: optional Build-Depends: perl, debhelper (>= 5) -Build-Depends-Indep: dpkg-dev (>= 1.9.0), libxml-simple-perl, markdown | libtext-markdown-perl, libtimedate-perl, libhtml-template-perl, libhtml-scrubber-perl, wdg-html-validator, libhtml-parser-perl, liburi-perl +Build-Depends-Indep: dpkg-dev (>= 1.9.0), libxml-simple-perl, libtext-markdown-perl | markdown, libtimedate-perl, libhtml-template-perl, libhtml-scrubber-perl, wdg-html-validator, libhtml-parser-perl, liburi-perl Maintainer: Joey Hess <[EMAIL PROTECTED]> Uploaders: Joey Hess <[EMAIL PROTECTED]>, Josh Triplett <[EMAIL PROTECTED]> Standards-Version: 3.8.0 index ac6d6db..0000000 diff --git a/doc/plugins/map.mdwn b/doc/plugins/map.mdwn index df34d77..af18a8f 100644 --- a/doc/plugins/map.mdwn +++ b/doc/plugins/map.mdwn @@ -1,8 +1,6 @@ [[template id=plugin name=map author="Alessandro Dotti Contra"]] [[tag type/meta]] -[[meta description="some page description"]] - This plugin generates a hierarchical page map for the wiki. Example usage: \[[map pages="* and !blog/* and !*/Discussion"]] diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 5def4c6..c9e4c4e 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -214,6 +214,17 @@ modify the body of a page after it has been fully converted to html. The function is passed named parameters: "page", "destpage", and "content", and should return the sanitized content. +### postscan + + hook(type => "postscan", id => "foo", call => \&postscan); + +This hook is called once the full page body is available (but before the +format hook). The most common use is to update search indexes. Added in +ikiwiki 2.54. + +The function is passed named parameters "page" and "content". Its return +value is ignored. + ### format hook(type => "format", id => "foo", call => \&format); @@ -559,12 +570,15 @@ time. This is the standard gettext function, although slightly optimised. -#### `urlto($$)` +#### `urlto($$;$)` Construct a relative url to the first parameter from the page named by the second. The first parameter can be either a page name, or some other destination file, as registered by `will_render`. +If the third parameter is passed and is true, an absolute url will be +constructed instead of the default relative url. + #### `targetpage($$)` Passed a page and an extension, returns the filename that page will be diff --git a/doc/smileys.mdwn b/doc/smileys.mdwn index 54ac539..4c19b05 100644 --- a/doc/smileys.mdwn +++ b/doc/smileys.mdwn @@ -1,47 +1,48 @@ This page is used to control what smileys are supported by the wiki. Just write the text of a smiley to display it. -* \:) [[smileys/smile.png]] -* \:-) [[smileys/smile.png]] -* \:D [[smileys/biggrin.png]] -* \:-D [[smileys/biggrin.png]] -* \B) [[smileys/smile2.png]] -* \B-) [[smileys/smile2.png]] -* \:)) [[smileys/smile3.png]] -* \:-)) [[smileys/smile3.png]] -* \;) [[smileys/smile4.png]] -* \;-) [[smileys/smile4.png]] -* \:\ [[smileys/ohwell.png]] -* \:-\ [[smileys/ohwell.png]] -* \:/ [[smileys/ohwell.png]] -* \:-/ [[smileys/ohwell.png]] -* \:| [[smileys/neutral.png]] -* \:-| [[smileys/neutral.png]] -* \>:> [[smileys/devil.png]] -* \X-( [[smileys/angry.png]] -* \<:( [[smileys/frown.png]] -* \:( [[smileys/sad.png]] -* \:-( [[smileys/sad.png]] -* \:-? [[smileys/tongue.png]] -* \:-P [[smileys/tongue.png]] -* \:o [[smileys/redface.png]] -* \|) [[smileys/tired.png]] -* \|-) [[smileys/tired.png]] -* \{OK} [[smileys/thumbs-up.png]] -* \{X} [[smileys/icon-error.png]] -* \{i} [[smileys/icon-info.png]] -* \(./) [[smileys/checkmark.png]] -* \(!) [[smileys/idea.png]] -* \[!] [[smileys/attention.png]] -* \/!\ [[smileys/alert.png]] -* \(?) [[smileys/question.png]] -* \{*} [[smileys/star_on.png]] -* \{o} [[smileys/star_off.png]] -* \{1} [[smileys/prio1.png]] -* \{2} [[smileys/prio2.png]] -* \{3} [[smileys/prio3.png]] +* \\:) [[smileys/smile.png]] +* \\:-) [[smileys/smile.png]] +* \\:D [[smileys/biggrin.png]] +* \\:-D [[smileys/biggrin.png]] +* \\B) [[smileys/smile2.png]] +* \\B-) [[smileys/smile2.png]] +* \\:)) [[smileys/smile3.png]] +* \\:-)) [[smileys/smile3.png]] +* \\;) [[smileys/smile4.png]] +* \\;-) [[smileys/smile4.png]] +* \\:\ [[smileys/ohwell.png]] +* \\:-\ [[smileys/ohwell.png]] +* \\:/ [[smileys/ohwell.png]] +* \\:-/ [[smileys/ohwell.png]] +* \\:| [[smileys/neutral.png]] +* \\:-| [[smileys/neutral.png]] +* \\>:> [[smileys/devil.png]] +* \\X-( [[smileys/angry.png]] +* \\<:( [[smileys/frown.png]] +* \\:( [[smileys/sad.png]] +* \\:-( [[smileys/sad.png]] +* \\:-? [[smileys/tongue.png]] +* \\:-P [[smileys/tongue.png]] +* \\:o [[smileys/redface.png]] +* \\|) [[smileys/tired.png]] +* \\|-) [[smileys/tired.png]] +* \\{OK} [[smileys/thumbs-up.png]] +* \\{X} [[smileys/icon-error.png]] +* \\{i} [[smileys/icon-info.png]] +* \\(./) [[smileys/checkmark.png]] +* \\(!) [[smileys/idea.png]] +* \\[!] [[smileys/attention.png]] +* \\/!\ [[smileys/alert.png]] +* \\(?) [[smileys/question.png]] +* \\{x} [[smileys/star_on.png]] +* \\{*} [[smileys/star_on.png]] +* \\{o} [[smileys/star_off.png]] +* \\{1} [[smileys/prio1.png]] +* \\{2} [[smileys/prio2.png]] +* \\{3} [[smileys/prio3.png]] -For example: {*} B) {*} +For example: {x} B) {x} ---- diff --git a/ikiwiki-transition b/ikiwiki-transition index e02c3aa..ce081fe 100755 --- a/ikiwiki-transition +++ b/ikiwiki-transition @@ -114,7 +114,7 @@ my $mode=shift; if ($mode eq 'prefix_directives') { prefix_directives(@ARGV); } -if ($mode eq 'hashpassword') { +elsif ($mode eq 'hashpassword') { hashpassword(@ARGV); } elsif ($mode eq 'indexdb') { diff --git a/templates/searchquery.tmpl b/templates/searchquery.tmpl index 0d6eb63..782b12c 100644 --- a/templates/searchquery.tmpl +++ b/templates/searchquery.tmpl @@ -1,5 +1,5 @@ $setmap{prefix,title,S} -$setmap{prefix,link,LINK} +$setmap{prefix,link,XLINK} $set{thousand,$.}$set{decimal,.}$setmap{BN,,Any Country,uk,England,fr,France} ${ $def{PREV,
signature.asc
Description: Digital signature