From bb84ce3d7e580247aaabd5440fe15a25206a40ed Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 19 Sep 2014 10:19:06 +0000 Subject: utf8 for everybody! diff --git a/authtoken.json b/authtoken.json index 2db49de..1f0c415 100755 --- a/authtoken.json +++ b/authtoken.json @@ -5,6 +5,10 @@ use File::Basename; use lib dirname( __FILE__ ) . '/lib'; use rddb; +binmode(STDIN, ":utf8"); +binmode(STDOUT, ":utf8"); +binmode(STDERR, ":utf8"); + my $status = 'ERROR'; my $errorstring = 'unknown'; my $username = ''; @@ -22,7 +26,7 @@ if(defined $ENV{REMOTE_USER}) { $errorstring = 'no username defined - are you logged in?'; } -print "Content-type: application/json\n\n"; +print "Content-type: application/json; charset=UTF-8\n\n"; print "{\n"; print ' "status": "' . $status . '"'. ",\n"; diff --git a/lib/rddb.pm b/lib/rddb.pm index 7a885be..b8188e2 100755 --- a/lib/rddb.pm +++ b/lib/rddb.pm @@ -21,6 +21,9 @@ sub opendb my $dbh = DBI->connect("DBI:mysql:$dbname:$dbhost","$dbuser","$dbpasswd") or return (undef, 'ERROR', "Database Error: " . $DBI::errstr); + $dbh->do(qq{SET CHARACTER SET utf8;}) + or return (undef, 'ERROR', "Database Error: " . $dbh->errstr); + return ($dbh, 'OK', 'success'); } diff --git a/listdrobpoxes.cgi b/listdrobpoxes.cgi index a6724d7..f2dec4f 100755 --- a/listdrobpoxes.cgi +++ b/listdrobpoxes.cgi @@ -6,13 +6,16 @@ use File::Basename; use lib dirname( __FILE__ ) . '/lib'; use rddb; +binmode(STDIN, ":utf8"); +binmode(STDOUT, ":utf8"); +binmode(STDERR, ":utf8"); + my $status = 'ERROR'; my $errorstring = 'unknown'; my $responsecode = 500; my @dropboxes = (); my $q = CGI->new; - my $username = $q->param('LOGIN_NAME'); my $token = $q->param('PASSWORD'); @@ -32,7 +35,7 @@ if(defined $dbh) { rddb::closedb($dbh); } -print "Content-type: application/xml\n\n"; +print "Content-type: application/xml; charset=UTF-8\n\n"; if($responsecode != 200) { print "\n"; -- cgit v0.10.2