Thread Fehlerhafte Eingabe erzeugt 500 Error anstatt Scriptfehlermeldung (38 answers)
Opened by Auctioneer at 2012-12-01 02:58

Auctioneer
 2012-12-01 02:58
#163807 #163807
User since
2008-09-30
26 Artikel
BenutzerIn
[Homepage] [default_avatar]
Hallo zusammen,

Perl Auktionsscript, Anmelderoutine: Benutzername besteht aus einem Wort.

Fehlermeldung meines Servers, wenn irrtümlich nach einem Wort ein Leerraum oder ein zweites Wort eingegeben wurde.

Er bringt diese Meldung nur, wenn irgend etwas gröberen Ausmasses nicht funzt wie falsches CHMODE...

So funktioniert natürlich auch dies nicht mehr:
use CGI::Carp qw(fatalsToBrowser);
BEGIN { open (STDERR, ">/home/........./error.txt"); }

und ich stehe im Regen...

---
Error message:
malformed header from script. Bad header=<table border=0 cellpadding=3 : auction.pl
---

So sieht es über dem HTML Startteil aus:

---
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Cookie Login
$config{'max_session_hours'} = 4; # Max session time before user must login again.
$config{'crypt_salt'} = 'EJ'; # You should make this 2 char salt unique.

local %form = &get_form_data unless %form;
use vars qw/%cookie $loginalias $loginpassword/;
my $cookieName = 'SessionCookie';
foreach my $rel(split /; /, $ENV{HTTP_COOKIE}){
next unless $rel=~s/^\Q$cookieName//;
my($bufName, $bufVal) = split(/=/, $rel);
$bufVal =~ s/%([a-fA-F0-9]{2})/pack("H2",$1)/eg;
$cookie{$bufName} = $bufVal;
}

my %LOGIN;
dbmopen(%LOGIN, 'Session_keys', 0644) or &oops('Cannot open login DBM keys.');
foreach(%LOGIN) { delete $LOGIN{$_} unless ($_ + $config{'max_session_hours'} * 3600 > time); }

if($config{'regdir'} ne ''){
$form{loginalias} = ucfirst lc $form{loginalias};
my ($password, $undef) = &read_reg_file($form{loginalias});

if (lc $form{loginpassword} eq lc $password) {
($loginalias, $loginpassword) = setlogin();
} else {
print "Location: $ENV{'SCRIPT_NAME'}\?action=reg\n\n";
}
}
untie(%LOGIN);

if ($form{'LOGOUT'}) {
foreach(%LOGIN) { delete ($LOGIN{$_}); }
print "Location: $ENV{'SCRIPT_NAME'}?action=logout\n\n";
}
# End Cookie Login
#-########################################
# Print The Page Header
#
print "Content-type: text/html\n\n";
print $config{'header'};


---

und hier ist das verify-login sub:

---

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#-########################################
# Sub: Verify a secure login

sub verify_login {
if ($loginalias ne '') {
my($password, $undef) = &read_reg_file($loginalias);
&oops('You must enter a valid username and password') unless ($loginpassword ne '');
&oops('Incorrect username or password.') unless ($loginpassword eq crypt((lc $password), $config{'crypt_salt'}));
$form{'ALIAS'} = $loginalias;
$form{'PASSWORD'} = $password;
#print "($loginalias)($password)";
return 1;
}else{
&login_form;

return '';
}
}
#-########################################


---

Ich such nun eine Lösung in Form einer OOPS Fehlermeldung anstelle des blöden 500 Errors auf der Seite, wie dies bei allen anderen fehlerhaften Eingaben auch der Fall ist, so ungefähr wie:

---
&oops('You must enter a one word username') unless ($loginalias ..ne oder eq.. '???');
---

Es kann sein, dass dieser Fehler immer schon existiert hat, aber noch nie von jemandem speziell erwähnt wurde. Ist auch schon länger her, dass die Login-Routine entwickelt worden ist...

Herzlichen Dank

Ernie

http://www.everyauction.info/cgi-bin/c/auction.pl?action=login
Last edited: 2012-12-01 03:09:35 +0100 (CET)
Never judge another men before you walk a mile in his shoes

View full thread Fehlerhafte Eingabe erzeugt 500 Error anstatt Scriptfehlermeldung