aggregate: Fix aggregation of posts without a title

When an aggregated post lacked a title, the code first prepended the
$feed->{dir} to it, and only then checked if it had zero length. So,
that check could never succeed and it was possible to end up with
$page="dir/", and writing to that would of course fail.

(Same problem could also occur when the whole title got sanitized away by the
wiki_file_regexp.)

Fixed by simply checking earlier if $page is empty.

Based on a patch by Alexandre Oliva which got lost in a maze of email
folders all alike for over two years despite him mentioning it to me at
least once in person.
master
Joey Hess 2018-10-28 18:57:45 -04:00
parent 9332b8115d
commit 0ec2c55ac0
No known key found for this signature in database
GPG Key ID: DB12DB0FF05F8F38
2 changed files with 6 additions and 2 deletions

View File

@ -7,6 +7,10 @@ ikiwiki (3.20180312) UNRELEASED; urgency=medium
[ Simon McVittie ]
* Hide popup template content from documentation (Closes: #898836)
[ Joey Hess ]
* aggregate: Fix aggregation of posts without a title.
Thanks, Alexandre Oliva
-- Simon McVittie <smcv@debian.org> Wed, 16 May 2018 13:09:27 +0100
ikiwiki (3.20180311) upstream; urgency=medium

View File

@ -621,11 +621,11 @@ sub add_page (@) {
# escape slashes and periods in title so it doesn't specify
# directory name or trigger ".." disallowing code.
$page=~s!([/.])!"__".ord($1)."__"!eg;
$page=$feed->{dir}."/".$page;
($page)=$page=~/$config{wiki_file_regexp}/;
if (! defined $page || ! length $page) {
$page=$feed->{dir}."/item";
}
$page=$feed->{dir}."/".$page;
($page)=$page=~/$config{wiki_file_regexp}/;
my $c="";
while (exists $IkiWiki::pagecase{lc $page.$c} ||
-e $IkiWiki::Plugin::transient::transientdir."/".htmlfn($page.$c) ||