X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/a2989598884807ace2a9efd248b7c32824cf6c6f..9f401d6617a11efcedda1c956b2ccea061a7540f:/IkiWiki/Plugin/comments.pm diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 17cd99c3b..d34951570 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -177,7 +177,7 @@ sub preprocess { if (defined $oiduser) { # looks like an OpenID $commentauthorurl = $commentuser; - $commentauthor = $oiduser; + $commentauthor = (defined $params{nickname} && length $params{nickname}) ? $params{nickname} : $oiduser; $commentopenid = $commentuser; } else { @@ -396,14 +396,18 @@ sub editcomment ($$) { my $content = "[[!comment format=$type\n"; - # FIXME: handling of double quotes probably wrong? if (defined $session->param('name')) { my $username = $session->param('name'); $username =~ s/"/"/g; $content .= " username=\"$username\"\n"; } - elsif (defined $ENV{REMOTE_ADDR}) { - my $ip = $ENV{REMOTE_ADDR}; + if (defined $session->param('nickname')) { + my $nickname = $session->param('nickname'); + $nickname =~ s/"/"/g; + $content .= " nickname=\"$nickname\"\n"; + } + elsif (defined $session->remote_addr()) { + my $ip = $session->remote_addr(); if ($ip =~ m/^([.0-9]+)$/) { $content .= " ip=\"$1\"\n"; } @@ -513,8 +517,10 @@ sub editcomment ($$) { IkiWiki::rcs_add($file); IkiWiki::disable_commit_hook(); - $conflict = IkiWiki::rcs_commit_staged($message, - $session->param('name'), $ENV{REMOTE_ADDR}); + $conflict = IkiWiki::rcs_commit_staged( + message => $message, + session => $session, + ); IkiWiki::enable_commit_hook(); IkiWiki::rcs_update(); } @@ -602,8 +608,10 @@ sub commentmoderation ($$) { if ($config{rcs} and $config{comments_commit}) { my $message = gettext("Comment moderation"); IkiWiki::disable_commit_hook(); - $conflict=IkiWiki::rcs_commit_staged($message, - $session->param('name'), $ENV{REMOTE_ADDR}); + $conflict=IkiWiki::rcs_commit_staged( + message => $message, + session => $session, + ); IkiWiki::enable_commit_hook(); IkiWiki::rcs_update(); } @@ -669,7 +677,7 @@ sub comments_pending () { my $extension=shift; return unless -d $dir; - chdir($dir) || die "chdir: $!"; + chdir($dir) || die "chdir $dir: $!"; find({ no_chdir => 1, @@ -686,7 +694,7 @@ sub comments_pending () { } }, "."); - chdir($origdir) || die "chdir: $!"; + chdir($origdir) || die "chdir $origdir: $!"; }; $find_comments->($config{srcdir}, "._comment_pending");