Browse Source

Fixed a bug with problematic chars in album names when trying to download them

Tobias Reich 10 years ago
parent
commit
1ecc81c18f
1 changed files with 10 additions and 4 deletions
  1. 10 4
      php/modules/Album.php

+ 10 - 4
php/modules/Album.php

@@ -237,6 +237,12 @@ class Album extends Module {
 		# Call plugins
 		$this->plugins(__METHOD__, 0, func_get_args());
 
+		# Illicit chars
+		$badChars =	array_merge(
+						array_map('chr', range(0,31)),
+						array("<", ">", ":", '"', "/", "\\", "|", "?", "*")
+					);
+
 		# Photos query
 		switch($this->albumIDs) {
 			case 's':
@@ -255,6 +261,10 @@ class Album extends Module {
 		# Set title
 		$album = $this->database->query("SELECT title FROM lychee_albums WHERE id = '$this->albumIDs' LIMIT 1;");
 		if ($this->albumIDs!=0&&is_numeric($this->albumIDs)) $zipTitle = $album->fetch_object()->title;
+
+		# Parse title
+		$zipTitle = str_replace($badChars, '', $zipTitle);
+
 		$filename = LYCHEE_DATA . $zipTitle . '.zip';
 
 		# Create zip
@@ -281,10 +291,6 @@ class Album extends Module {
 			$photo->url = LYCHEE_UPLOADS_BIG . $photo->url;
 
 			# Parse title
-			$badChars =	array_merge(
-							array_map('chr', range(0,31)),
-							array("<", ">", ":", '"', "/", "\\", "|", "?", "*")
-						);
 			$photo->title = str_replace($badChars, '', $photo->title);
 			if (!isset($photo->title)||$photo->title==='') $photo->title = 'Untitled';