stop using REMOTE_ADDR
Everywhere that REMOTE_ADDR was used, a session object is available, so instead use its remote_addr method. In IkiWiki::Receive, stop setting a dummy REMOTE_ADDR. Note that it's possible for a session cookie to be obtained using one IP address, and then used from another IP. In this case, the first IP will now be used. I think that should be ok.master
parent
b4a43406f6
commit
4292802ee5
|
@ -283,7 +283,7 @@ sub check_banned ($$) {
|
|||
|
||||
foreach my $b (@{$config{banned_users}}) {
|
||||
if (pagespec_match("", $b,
|
||||
ip => $ENV{REMOTE_ADDR},
|
||||
ip => $session->remote_addr(),
|
||||
name => defined $name ? $name : "",
|
||||
)) {
|
||||
$banned=1;
|
||||
|
|
|
@ -58,7 +58,7 @@ sub check_canattach ($$;$) {
|
|||
$config{allowed_attachments},
|
||||
file => $file,
|
||||
user => $session->param("name"),
|
||||
ip => $ENV{REMOTE_ADDR},
|
||||
ip => $session->remote_addr(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,8 @@ sub formbuilder (@) {
|
|||
IkiWiki::disable_commit_hook();
|
||||
IkiWiki::rcs_commit($filename, gettext("attachment upload"),
|
||||
IkiWiki::rcs_prepedit($filename),
|
||||
$session->param("name"), $ENV{REMOTE_ADDR});
|
||||
$session->param("name"),
|
||||
$session->remote_addr());
|
||||
IkiWiki::enable_commit_hook();
|
||||
IkiWiki::rcs_update();
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ sub checkconfig () {
|
|||
|
||||
sub checkcontent (@) {
|
||||
my %params=@_;
|
||||
my $session=$params{session};
|
||||
|
||||
if (exists $config{blogspam_pagespec}) {
|
||||
return undef
|
||||
|
@ -88,7 +89,7 @@ sub checkcontent (@) {
|
|||
push @options, "exclude=stopwords";
|
||||
|
||||
my %req=(
|
||||
ip => $ENV{REMOTE_ADDR},
|
||||
ip => $session->remote_addr(),
|
||||
comment => defined $params{diff} ? $params{diff} : $params{content},
|
||||
subject => defined $params{subject} ? $params{subject} : "",
|
||||
name => defined $params{author} ? $params{author} : "",
|
||||
|
|
|
@ -402,8 +402,8 @@ sub editcomment ($$) {
|
|||
$username =~ s/"/"/g;
|
||||
$content .= " username=\"$username\"\n";
|
||||
}
|
||||
elsif (defined $ENV{REMOTE_ADDR}) {
|
||||
my $ip = $ENV{REMOTE_ADDR};
|
||||
elsif (defined $session->remote_addr()) {
|
||||
my $ip = $session->remote_addr();
|
||||
if ($ip =~ m/^([.0-9]+)$/) {
|
||||
$content .= " ip=\"$1\"\n";
|
||||
}
|
||||
|
@ -514,7 +514,8 @@ sub editcomment ($$) {
|
|||
IkiWiki::rcs_add($file);
|
||||
IkiWiki::disable_commit_hook();
|
||||
$conflict = IkiWiki::rcs_commit_staged($message,
|
||||
$session->param('name'), $ENV{REMOTE_ADDR});
|
||||
$session->param('name'),
|
||||
$session->remote_addr());
|
||||
IkiWiki::enable_commit_hook();
|
||||
IkiWiki::rcs_update();
|
||||
}
|
||||
|
@ -603,7 +604,8 @@ sub commentmoderation ($$) {
|
|||
my $message = gettext("Comment moderation");
|
||||
IkiWiki::disable_commit_hook();
|
||||
$conflict=IkiWiki::rcs_commit_staged($message,
|
||||
$session->param('name'), $ENV{REMOTE_ADDR});
|
||||
$session->param('name'),
|
||||
$session->remote_addr());
|
||||
IkiWiki::enable_commit_hook();
|
||||
IkiWiki::rcs_update();
|
||||
}
|
||||
|
|
|
@ -403,7 +403,8 @@ sub cgi_editpage ($$) {
|
|||
disable_commit_hook();
|
||||
$conflict=rcs_commit($file, $message,
|
||||
$form->field("rcsinfo"),
|
||||
$session->param("name"), $ENV{REMOTE_ADDR});
|
||||
$session->param("name"),
|
||||
$session->remote_addr());
|
||||
enable_commit_hook();
|
||||
rcs_update();
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ sub canedit ($$) {
|
|||
if (defined $config{locked_pages} && length $config{locked_pages} &&
|
||||
pagespec_match($page, $config{locked_pages},
|
||||
user => $session->param("name"),
|
||||
ip => $ENV{REMOTE_ADDR},
|
||||
ip => $session->remote_addr(),
|
||||
)) {
|
||||
if ((! defined $user ||
|
||||
! IkiWiki::userinfo_get($session->param("name"), "regdate")) &&
|
||||
|
|
|
@ -48,11 +48,11 @@ sub checkcontent (@) {
|
|||
}
|
||||
|
||||
my $session=$params{session};
|
||||
my $user=$session->param("name") if $session;
|
||||
my $user=$session->param("name");
|
||||
if (pagespec_match($params{page}, $config{moderate_pagespec},
|
||||
location => $params{page},
|
||||
(defined $user ? (user => $user) : ()),
|
||||
(defined $ENV{REMOTE_ADDR} ? (ip => $ENV{REMOTE_ADDR}) : ()),
|
||||
(defined $session->remote_addr() ? (ip => $session->remote_addr()) : ()),
|
||||
)) {
|
||||
return gettext("comment needs moderation");
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ sub formbuilder (@) {
|
|||
),
|
||||
wikiurl => $config{url},
|
||||
wikiname => $config{wikiname},
|
||||
REMOTE_ADDR => $ENV{REMOTE_ADDR},
|
||||
remote_addr => $session->remote_addr(),
|
||||
);
|
||||
|
||||
eval q{use Mail::Sendmail};
|
||||
|
|
|
@ -136,7 +136,8 @@ sub sessioncgi ($$) {
|
|||
IkiWiki::disable_commit_hook();
|
||||
IkiWiki::rcs_commit($pagesources{$page}, "poll vote ($choice)",
|
||||
IkiWiki::rcs_prepedit($pagesources{$page}),
|
||||
$session->param("name"), $ENV{REMOTE_ADDR});
|
||||
$session->param("name"),
|
||||
$session->remote_addr());
|
||||
IkiWiki::enable_commit_hook();
|
||||
IkiWiki::rcs_update();
|
||||
}
|
||||
|
|
|
@ -214,7 +214,8 @@ sub sessioncgi ($$) {
|
|||
IkiWiki::rcs_remove($file);
|
||||
}
|
||||
IkiWiki::rcs_commit_staged(gettext("removed"),
|
||||
$session->param("name"), $ENV{REMOTE_ADDR});
|
||||
$session->param("name"),
|
||||
$session->remote_addr());
|
||||
IkiWiki::enable_commit_hook();
|
||||
IkiWiki::rcs_update();
|
||||
}
|
||||
|
|
|
@ -350,7 +350,9 @@ sub sessioncgi ($$) {
|
|||
}
|
||||
IkiWiki::rcs_commit_staged(
|
||||
sprintf(gettext("rename %s to %s"), $srcfile, $destfile),
|
||||
$session->param("name"), $ENV{REMOTE_ADDR}) if $config{rcs};
|
||||
$session->param("name"),
|
||||
$session->remote_addr(),
|
||||
) if $config{rcs};
|
||||
|
||||
# Then link fixups.
|
||||
foreach my $rename (@torename) {
|
||||
|
@ -576,7 +578,7 @@ sub fixlinks ($$$) {
|
|||
sprintf(gettext("update for rename of %s to %s"), $rename->{srcfile}, $rename->{destfile}),
|
||||
$token,
|
||||
$session->param("name"),
|
||||
$ENV{REMOTE_ADDR}
|
||||
$session->remote_addr(),
|
||||
);
|
||||
push @fixedlinks, $page if ! defined $conflict;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ sub test () {
|
|||
eval q{use CGI};
|
||||
error($@) if $@;
|
||||
my $cgi=CGI->new;
|
||||
$ENV{REMOTE_ADDR}='unknown' unless exists $ENV{REMOTE_ADDR};
|
||||
|
||||
# And dummy up a session object.
|
||||
require IkiWiki::CGI;
|
||||
|
|
Loading…
Reference in New Issue