bugfix
authorJoey Hess <joey@kitenet.net>
Fri, 7 May 2010 17:47:29 +0000 (13:47 -0400)
committerJoey Hess <joey@kitenet.net>
Fri, 7 May 2010 17:47:29 +0000 (13:47 -0400)
IkiWiki/Plugin/comments.pm

index 93c8c4061b111cae5a2ece8bd94c5a77c7957f7f..077c4776bb85e68337bf356093e20a0b5c087290 100644 (file)
@@ -473,7 +473,7 @@ sub editcomment ($$) {
                $postcomment=0;
 
                if (! $ok) {
-                       $location=unique_comment_location($page, $content, $config{srcdir});
+                       $location=unique_comment_location($page, $content, $config{srcdir}, "._comment_pending");
                        writefile("$location._comment_pending", $config{srcdir}, $content);
 
                        # Refresh so anything that deals with pending
@@ -858,22 +858,20 @@ sub num_comments ($$) {
        return @comments;
 }
 
-sub unique_comment_location ($$$) {
+sub unique_comment_location ($$$$) {
        my $page=shift;
-
        eval q{use Digest::MD5 'md5_hex'};
        error($@) if $@;
        my $content_md5=md5_hex(Encode::encode_utf8(shift));
-
        my $dir=shift;
+       my $ext=shift || "._comment";
 
        my $location;
        my $i = num_comments($page, $dir);
        do {
                $i++;
                $location = "$page/$config{comments_pagename}${i}_${content_md5}";
-       } while (-e "$dir/$location._comment" ||
-                -e "$dir/$location._comment_pending");
+       } while (-e "$dir/$location$ext");
 
        return $location;
 }