draigwen (
draigwen) wrote in
dw_dev_training2009-08-08 10:09 pm
Need help with POST and referer stuff
I'm trying to get back into fixing bugs, etc, again, but my head is spinning and I think I'm beginning to regret it! ;)
Some help would be appreciated to help get my head around something. I'm currently looking at bug 1557.
I'm fairly comfortable with the gist of the bug, and of the two pages mentioned I think I can fix interests.bml with no problem at all. The problem is with login.bml. It's not so much using check_referer that I'm struggling with, but the redirecting once the referer has been checked.
The code I'm looking at is:
Firstly, I don't quite understand the difference between the if and else statements: what are $referer, $POST{'ref'}, and $GET{'ret'}? I think being comfortable with the difference between these three would help greatly.
The second (which may be cleared up by the answer to the first problem), is that if I get rid of my
Hope my questions make a little sense. It's late so I'll probably look at this again in the morning. At least I can fix some of the more simple files!
Some help would be appreciated to help get my head around something. I'm currently looking at bug 1557.
I'm fairly comfortable with the gist of the bug, and of the two pages mentioned I think I can fix interests.bml with no problem at all. The problem is with login.bml. It's not so much using check_referer that I'm struggling with, but the redirecting once the referer has been checked.
The code I'm looking at is:
my $referer = BML::get_client_header('Referer');
if ($POST{'ref'} =~ /\Q$LJ::DOMAIN\E/ && $POST{'ref'} !~ m!/logout\.bml$! &&
$POST{'ref'} !~ /[\n\r]/)
{
return BML::redirect("$POST{'ref'}");
} elsif ($GET{'ret'} == 1 && $referer && $referer =~ /\Q$LJ::DOMAIN\E/) {
my $uniq = BML::get_request()->notes->{uniq};
if ($uniq) {
LJ::MemCache::set("loginout:$uniq", 1, time() + 15);
}
return BML::redirect("$referer");
}Firstly, I don't quite understand the difference between the if and else statements: what are $referer, $POST{'ref'}, and $GET{'ret'}? I think being comfortable with the difference between these three would help greatly.
The second (which may be cleared up by the answer to the first problem), is that if I get rid of my
$referer = BML::get_client_header('Referer'); then what do I redirect to in the second instance?Hope my questions make a little sense. It's late so I'll probably look at this again in the morning. At least I can fix some of the more simple files!

no subject