Update packaging based on lintian output
[mirror/userdir-ldap-cgi.git] / Util.pm
diff --git a/Util.pm b/Util.pm
index e30faa6..1688dc4 100644 (file)
--- a/Util.pm
+++ b/Util.pm
@@ -171,15 +171,17 @@ sub FormatFingerPrint {
       $out .= " " if ($_ == 7);
     }      
   } else {
-    foreach (0..int(length($in)/2)) {
+    foreach (0..int(length($in)/4)) {
       $out .= substr($in, $_*4, 4)." ";
     }      
   }
+  chop $out;
   return $out;
 }
 
 sub FetchKey {
   my $fingerprint = shift;
+  my $signatures = shift;
   my ($out, $keyringparam) = undef;
   
   foreach (split(/:/, $config{keyrings})) {
@@ -191,9 +193,11 @@ sub FetchKey {
 
   local $ENV{PATH} = '';
   $/ = undef; # just suck it up ....
-  open(FP, "$config{gpg} --no-options --no-default-keyring $keyringparam --list-sigs --fingerprint $fingerprint|");
-  $out = <FP>;
-  close FP;
+  if ($signatures) {
+      open(FP, "$config{gpg} --no-options --no-default-keyring $keyringparam --list-sigs --fingerprint $fingerprint|");
+      $out = <FP>;
+      close FP;
+  }
   open(FP, "$config{gpg} --no-options --no-default-keyring $keyringparam --export -a $fingerprint|");
   $out .= <FP>;
   close FP;
@@ -253,7 +257,7 @@ sub LookupCountry {
 my $htmlhdrsent = 0;
 
 sub HTMLSendHeader {
-  print "Content-type: text/html\n\n" if (!$htmlhdrsent);
+  print "Content-type: text/html; charset=utf-8\n\n" if (!$htmlhdrsent);
   $htmlhdrsent = 1;
 }
 
@@ -322,7 +326,8 @@ sub ReadConfigFile {
     if ((!/^\s*#/) && ($_ ne "")) {
       # Chop off any trailing comments
       s/#.*//;
-      ($attr, $setting) = split(/=/, $_, 2);
+      /([^=]+)=(.*)/;
+      ($attr, $setting) = ($1, $2);
       $setting =~ s/"//g; #"
       $setting =~ s/;$//;
       $attr =~ s/^\s+//; $attr =~ s/\s+$//;