<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -96,11 +96,8 @@ if ((substr($uri, 0,7) == &quot;http://&quot;) || (substr($uri, 0,8) == &quot;https://&quot;)) {
   $doc-&gt;formatOutput = true;
   $Str = $xsl-&gt;transformToXML($doc);
 
-
   // check to see if a filename is specified
-  if (isset($_GET['filename'])){
-    if ($_GET['filename'] != ''){ $logfile = $_GET['filename']; }
-  } else {
+  if ( empty( @$_GET['filename'] ) or strlen( @$_GET['filename'] &gt; 0 ) ) {
     # look for the fullname so we can name the vcard
     preg_match_all( '/FN.*?:(.*)/i', $Str, &amp;$matches);
     # we will get the matched line and all matches for our requested parameter
@@ -109,21 +106,27 @@ if ((substr($uri, 0,7) == &quot;http://&quot;) || (substr($uri, 0,8) == &quot;https://&quot;)) {
     if ( count($matches[1]) &gt; 2 ) {
       $logfile = parse_url($uri);
       $logfile = str_replace( '.', '-', $logfile['host'] );
-    # else try and get the fn name
-    } elseif ( ! $logfile = @trim($matches[1][0]) ) {
-      # failsafe x2v filename
-      $logfile = &quot;X2V&quot;;
+    } else {
+      # else try and get the fn name
+      $logfile = @trim($matches[1][0]);
     }
+  } else {
+    $logfile = $_GET['filename'];
   }
 
   # get the filename encoding correct
-  $logfile = utf8_decode( $logfile );
+  $logfile = str_replace( ' ', '-', utf8_decode( $logfile ) );
+  
+  if ( strlen( $logfile ) &lt; 1 ) {
+    # failsafe x2v filename
+    $logfile = &quot;X2V&quot;;
+  }
 
   if (FALSE == $Str){
     print 'No vCards found';
     //print '&lt;!-- '.htmlentities($xml_string).' --&gt;';
   } else {
-    header(&quot;Content-Disposition: attachment; filename=\&quot;$logfile.$extension\&quot;&quot;);
+    header(&quot;Content-Disposition: attachment; filename=$logfile.$extension&quot;);
   //  header(&quot;Content-Length: &quot;.mb_strlen($Str)+1);
     header(&quot;Connection: close&quot;);
     header(&quot;Content-Type: $contentType; charset=&quot;.X2V_CHARSET.&quot;; name=$logfile.$extension&quot;);</diff>
      <filename>get-contact-named-vcf.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a94b8a8cbe01516fb417979dc92df4fd9fb55278</id>
    </parent>
  </parents>
  <author>
    <name>Matt</name>
    <email>matt@themattharris.com</email>
  </author>
  <url>http://github.com/themattharris/x2v/commit/1c6f42ccd058c2c8ef0e3c72fd1e5d0354ff6fd6</url>
  <id>1c6f42ccd058c2c8ef0e3c72fd1e5d0354ff6fd6</id>
  <committed-date>2009-10-29T18:09:09-07:00</committed-date>
  <authored-date>2009-10-29T18:09:09-07:00</authored-date>
  <message>cleaned up the filenaming code</message>
  <tree>8c903b11dbe818d7de5764d8aaa657a8ca123139</tree>
  <committer>
    <name>Matt</name>
    <email>matt@themattharris.com</email>
  </committer>
</commit>
