editpage: Avoid storing accidental state changes when previewing pages.
This is a slow, safe, stupid approach. Could make deep copies of the data structures as backups instead of re-loading the index from disk.master
parent
b2327cfae4
commit
24b59b3a9e
|
@ -170,10 +170,8 @@ sub cgi_editpage ($$) {
|
||||||
$previewing=1;
|
$previewing=1;
|
||||||
|
|
||||||
my $new=not exists $pagesources{$page};
|
my $new=not exists $pagesources{$page};
|
||||||
if ($new) {
|
# temporarily record its type
|
||||||
# temporarily record its type
|
$pagesources{$page}=$page.".".$type if $new;
|
||||||
$pagesources{$page}=$page.".".$type;
|
|
||||||
}
|
|
||||||
my %wasrendered=map { $_ => 1 } @{$renderedfiles{$page}};
|
my %wasrendered=map { $_ => 1 } @{$renderedfiles{$page}};
|
||||||
|
|
||||||
my $content=$form->field('editcontent');
|
my $content=$form->field('editcontent');
|
||||||
|
@ -198,18 +196,17 @@ sub cgi_editpage ($$) {
|
||||||
});
|
});
|
||||||
$form->tmpl_param("page_preview", $preview);
|
$form->tmpl_param("page_preview", $preview);
|
||||||
|
|
||||||
if ($new) {
|
|
||||||
delete $pagesources{$page};
|
|
||||||
}
|
|
||||||
|
|
||||||
# Previewing may have created files on disk.
|
# Previewing may have created files on disk.
|
||||||
# Keep a list of these to be deleted later.
|
# Keep a list of these to be deleted later.
|
||||||
my %previews = map { $_ => 1 } @{$wikistate{editpage}{previews}};
|
my %previews = map { $_ => 1 } @{$wikistate{editpage}{previews}};
|
||||||
foreach my $f (@{$renderedfiles{$page}}) {
|
foreach my $f (@{$renderedfiles{$page}}) {
|
||||||
$previews{$f}=1 unless $wasrendered{$f};
|
$previews{$f}=1 unless $wasrendered{$f};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Throw out any other state changes made during previewing,
|
||||||
|
# and save the previews list.
|
||||||
|
loadindex();
|
||||||
@{$wikistate{editpage}{previews}} = keys %previews;
|
@{$wikistate{editpage}{previews}} = keys %previews;
|
||||||
$renderedfiles{$page}=[keys %wasrendered];
|
|
||||||
saveindex();
|
saveindex();
|
||||||
}
|
}
|
||||||
elsif ($form->submitted eq "Save Page") {
|
elsif ($form->submitted eq "Save Page") {
|
||||||
|
|
|
@ -8,6 +8,7 @@ ikiwiki (3.20100609) unstable; urgency=low
|
||||||
* Fix support for globbing in tagged() pagespecs.
|
* Fix support for globbing in tagged() pagespecs.
|
||||||
* Fix display of sidebar when previewing page edit. (Thanks, privat)
|
* Fix display of sidebar when previewing page edit. (Thanks, privat)
|
||||||
* relativedate: Fix problem with localised dates not working.
|
* relativedate: Fix problem with localised dates not working.
|
||||||
|
* editpage: Avoid storing accidental state changes when previewing pages.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Mon, 31 May 2010 20:44:17 -0400
|
-- Joey Hess <joeyh@debian.org> Mon, 31 May 2010 20:44:17 -0400
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
If `comments_allowdirectives` is set, previewing a comment can run
|
||||||
|
directives that create files. (Eg, img.) Unlike editpage, it does not
|
||||||
|
keep track of those files and expire them. So the files will linger in
|
||||||
|
destdir forever.
|
||||||
|
|
||||||
|
Probably when the user then tries to save the comment, ikiwiki will refuse
|
||||||
|
to overwrite the unknown file, and will crash.
|
||||||
|
--[[Joey]]
|
|
@ -9,3 +9,5 @@ saves other state changes.
|
||||||
|
|
||||||
Seems like it needs to isolate all state changes when previewing... ugh.
|
Seems like it needs to isolate all state changes when previewing... ugh.
|
||||||
--[[Joey]]
|
--[[Joey]]
|
||||||
|
|
||||||
|
[[done]]
|
||||||
|
|
Loading…
Reference in New Issue