X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/18eeb068a6be7e45add2775a4014c85e3b41b465..9557c7c8905f08361aabd1215fa3bc19badf9a4f:/IkiWiki/Plugin/comments.pm diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 4999c3f24..c458ea9da 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -112,12 +112,12 @@ sub preprocess { # {{{ my $page = $params{page}; my $format = $params{format}; - if (defined $format && !exists $IkiWiki::hooks{htmlize}{$format}) { + if (defined $format && ! exists $IkiWiki::hooks{htmlize}{$format}) { error(sprintf(gettext("unsupported page format %s"), $format)); } my $content = $params{content}; - if (!defined $content) { + if (! defined $content) { error(gettext("comment must have content")); } $content =~ s/\\"/"/g; @@ -165,10 +165,10 @@ sub preprocess { # {{{ $pagestate{$page}{comments}{commentip} = $commentip; $pagestate{$page}{comments}{commentauthor} = $commentauthor; $pagestate{$page}{comments}{commentauthorurl} = $commentauthorurl; - if (!defined $pagestate{$page}{meta}{author}) { + if (! defined $pagestate{$page}{meta}{author}) { $pagestate{$page}{meta}{author} = $commentauthor; } - if (!defined $pagestate{$page}{meta}{authorurl}) { + if (! defined $pagestate{$page}{meta}{authorurl}) { $pagestate{$page}{meta}{authorurl} = $commentauthorurl; } @@ -221,7 +221,7 @@ sub linkcgi ($) { #{{{ if (defined $cgi->param('do') && $cgi->param('do') eq "commenter") { my $page=decode_utf8($cgi->param("page")); - if (!defined $page) { + if (! defined $page) { error("missing page parameter"); } @@ -310,7 +310,7 @@ sub sessioncgi ($$) { #{{{ } my @page_types; if (exists $IkiWiki::hooks{htmlize}) { - @page_types = grep { !/^_/ } keys %{$IkiWiki::hooks{htmlize}}; + @page_types = grep { ! /^_/ } keys %{$IkiWiki::hooks{htmlize}}; } my $allow_author = $config{comments_allowauthor}; @@ -326,7 +326,7 @@ sub sessioncgi ($$) { #{{{ $form->tmpl_param(username => $session->param('name')); - if ($allow_author and !defined $session->param('name')) { + if ($allow_author and ! defined $session->param('name')) { $form->tmpl_param(allowauthor => 1); $form->field(name => 'author', type => 'text', size => '40'); $form->field(name => 'url', type => 'text', size => '40'); @@ -343,7 +343,7 @@ sub sessioncgi ($$) { #{{{ # it to file_pruned anyway my $page = $form->field('page'); $page = IkiWiki::possibly_foolish_untaint($page); - if (!defined $page || !length $page || + if (! defined $page || ! length $page || IkiWiki::file_pruned($page, $config{srcdir})) { error(gettext("bad page name")); } @@ -391,10 +391,6 @@ sub sessioncgi ($$) { #{{{ IkiWiki::check_canedit($page, $cgi, $session); $postcomment=0; - my $editcontent = $form->field('editcontent') || ''; - $editcontent =~ s/\r\n/\n/g; - $editcontent =~ s/\r/\n/g; - # FIXME: check that the wiki is locked right now, because # if it's not, there are mad race conditions! @@ -409,7 +405,6 @@ sub sessioncgi ($$) { #{{{ my $anchor = "${comments_pagename}${i}"; - $editcontent =~ s/"/\\"/g; my $content = "[[!_comment format=$type\n"; # FIXME: handling of double quotes probably wrong? @@ -446,6 +441,10 @@ sub sessioncgi ($$) { #{{{ $content .= " date=\"" . decode_utf8(strftime('%Y-%m-%dT%H:%M:%SZ', gmtime)) . "\"\n"; + my $editcontent = $form->field('editcontent') || ''; + $editcontent =~ s/\r\n/\n/g; + $editcontent =~ s/\r/\n/g; + $editcontent =~ s/"/\\"/g; $content .= " content=\"\"\"\n$editcontent\n\"\"\"]]\n"; # This is essentially a simplified version of editpage: