From 1ecc81c18f9b9892ab819fdd9b42daee7c8103f9 Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Wed, 18 Jun 2014 23:36:00 +0200 Subject: [PATCH] Fixed a bug with problematic chars in album names when trying to download them --- php/modules/Album.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/php/modules/Album.php b/php/modules/Album.php index 82b82c3..a8cfca6 100644 --- a/php/modules/Album.php +++ b/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';