Index: tilesGen.pl
===================================================================
--- tilesGen.pl	(revision 1778)
+++ tilesGen.pl	(working copy)
@@ -108,7 +108,7 @@
   my ($ValidFlag,$Version,$X,$Y,$Z,$ModuleName) = split(/\|/, $Request);
   
   # First field is always "OK" if the server has actually sent a request
-  if($ValidFlag != "OK"){
+  if($ValidFlag ne "OK"){
     print "Server didn't really give a good answer\n";
     return;
   }
@@ -140,25 +140,26 @@
   my $OsmOK = 0;
   
   while(my $Line = <$fp>){
-    next if($Line =~ /^\s*#/); # Comments
+    $Line =~ s/\r//g;
+    $Line =~ s/\n//g;
     
-    if ($Line =~ /WorkingDirectory=(.*)/) { $WorkingDirectory=$1; $OsmOK++; } 
-    if ($Line =~ /Inkscape=(.*)/)        { $Inkscape=$1;       $OsmOK++; } 
-    if ($Line =~ /XmlStarlet=(.*)/)      { $XmlStarlet=$1;     $OsmOK++; } 
-    if ($Line =~ /Niceness=(.*)/)        { $Niceness=$1;       $OsmOK++; } 
+    if ($Line =~ /^WorkingDirectory=(.*)/) { $WorkingDirectory=$1; $OsmOK++; } 
+    if ($Line =~ /^Inkscape=(.*)/)        { $Inkscape=$1;       $OsmOK++; } 
+    if ($Line =~ /^XmlStarlet=(.*)/)      { $XmlStarlet=$1;     $OsmOK++; } 
+    if ($Line =~ /^Niceness=(.*)/)        { $Niceness=$1;       $OsmOK++; } 
 
-    if ($Line =~ /UploadURL=(.*)/)       { $UploadURL=$1;      $OsmOK++; } 
-    if ($Line =~ /UploadUsername=(.*)/)  { $UploadUsername=$1; $OsmOK++; } 
-    if ($Line =~ /UploadPassword=(.*)/)  { $UploadPassword=$1; $OsmOK++; } 
+    if ($Line =~ /^UploadURL=(.*)/)       { $UploadURL=$1;      $OsmOK++; } 
+    if ($Line =~ /^UploadUsername=(.*)/)  { $UploadUsername=$1; $OsmOK++; } 
+    if ($Line =~ /^UploadPassword=(.*)/)  { $UploadPassword=$1; $OsmOK++; } 
 
-    if ($Line =~ /OsmUsername=(.*)/)     { $OsmUsername=$1;    $OsmOK++; } # TODO convert @ to %40
-    if ($Line =~ /OsmPassword=(.*)/)     { $OsmPassword=$1;    $OsmOK++; } 
+    if ($Line =~ /^OsmUsername=(.*)/)     { $OsmUsername=$1;    $OsmOK++; }
+    if ($Line =~ /^OsmPassword=(.*)/)     { $OsmPassword=$1;    $OsmOK++; } 
 
-    if ($Line =~ /BorderN=(.*)/)         { $BorderN=$1;        $OsmOK++; } 
-    if ($Line =~ /BorderS=(.*)/)         { $BorderS=$1;        $OsmOK++; } 
-    if ($Line =~ /BorderE=(.*)/)         { $BorderE=$1;        $OsmOK++; } 
-    if ($Line =~ /BorderW=(.*)/)         { $BorderW=$1;        $OsmOK++; } 
-    if ($Line =~ /MaxZoom=(.*)/)         { $MaxZoom=$1;        $OsmOK++; } 
+    if ($Line =~ /^BorderN=(.*)/)         { $BorderN=$1;        $OsmOK++; } 
+    if ($Line =~ /^BorderS=(.*)/)         { $BorderS=$1;        $OsmOK++; } 
+    if ($Line =~ /^BorderE=(.*)/)         { $BorderE=$1;        $OsmOK++; } 
+    if ($Line =~ /^BorderW=(.*)/)         { $BorderW=$1;        $OsmOK++; } 
+    if ($Line =~ /^MaxZoom=(.*)/)         { $MaxZoom=$1;        $OsmOK++; } 
 
   }
   close $fp;
@@ -166,6 +167,7 @@
   if($OsmOK != 14){
     die("Check your .conf file - some entries not found");
   }
+  $OsmUsername =~ s/@/%40/g;
 }
 
 #-----------------------------------------------------------------------------
Index: upload.pl
===================================================================
--- upload.pl	(revision 1778)
+++ upload.pl	(working copy)
@@ -150,7 +150,9 @@
   open(my $fp, "<", shift()) || die("Can't open config file\n");
   foreach my $Line(<$fp>){
     $Line =~ s/\s*#.*$//; # Strip out comments
-    if($Line =~ /(\w+)=(.*)/){
+    $Line =~ s/\n//g;     # removes LF
+    $Line =~ s/\r//g;     # removes CR
+    if($Line =~ /^(\w+)=(.*)/){
       $Config{$1} = $2;
     }
   }
