Fix snapshots on repos with special characters in the name/directory
Fix snapshots on repos with special characters in the name/directory

The prefix parameter needed to be quoted to ensure the archive command went through successfully

--- a/include/Util.class.php
+++ b/include/Util.class.php
@@ -68,10 +68,10 @@
 	public static function MakeSlug($str)
 	{
 		$from = array(
-			'/'
+			'/&'
 		);
 		$to = array(
-			'-'
+			'--'
 		);
 		return str_replace($from, $to, $str);
 	}

--- a/include/git/archive/Archive_Bzip2.class.php
+++ b/include/git/archive/Archive_Bzip2.class.php
@@ -70,7 +70,7 @@
 
 		$args = array();
 		$args[] = '--format=tar';
-		$args[] = '--prefix=' . $archive->GetPrefix();
+		$args[] = "--prefix='" . $archive->GetPrefix() . "'";
 		$args[] = $archive->GetObject()->GetHash();
 
 		$this->handle = $this->exe->Open($archive->GetProject()->GetPath(), GIT_ARCHIVE, $args);

--- a/include/git/archive/Archive_Gzip.class.php
+++ b/include/git/archive/Archive_Gzip.class.php
@@ -77,7 +77,7 @@
 
 		$args = array();
 		$args[] = '--format=tar';
-		$args[] = '--prefix=' . $archive->GetPrefix();
+		$args[] = "--prefix='" . $archive->GetPrefix() . "'";
 		$args[] = $archive->GetObject()->GetHash();
 
 		$this->handle = $this->exe->Open($archive->GetProject()->GetPath(), GIT_ARCHIVE, $args);

--- a/include/git/archive/Archive_Tar.class.php
+++ b/include/git/archive/Archive_Tar.class.php
@@ -50,7 +50,7 @@
 
 		$args = array();
 		$args[] = '--format=tar';
-		$args[] = '--prefix=' . $archive->GetPrefix();
+		$args[] = "--prefix='" . $archive->GetPrefix() . "'";
 		$args[] = $archive->GetObject()->GetHash();
 
 		$this->handle = $this->exe->Open($archive->GetProject()->GetPath(), GIT_ARCHIVE, $args);

--- a/include/git/archive/Archive_Zip.class.php
+++ b/include/git/archive/Archive_Zip.class.php
@@ -72,7 +72,7 @@
 		$args[] = '--format=zip';
 		if ($this->compressLevel)
 			$args[] = '-' . $this->compressLevel;
-		$args[] = '--prefix=' . $archive->GetPrefix();
+		$args[] = "--prefix='" . $archive->GetPrefix() . "'";
 		$args[] = $archive->GetObject()->GetHash();
 
 		$this->handle = $this->exe->Open($archive->GetProject()->GetPath(), GIT_ARCHIVE, $args);

comments