diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php
index 187cd8af2923b7f4cb9db552dd439132ce78bc77..1233b49052fbc110749084976c33c7c4a2f4c631 100644
--- a/apps/gallery/ajax/galleryOp.php
+++ b/apps/gallery/ajax/galleryOp.php
@@ -104,7 +104,7 @@ if ($_GET['operation']) {
 	  OC_JSON::success();
     break;
   case 'get_covers':
-    handleGetThumbnails($_GET['albumname']);
+    handleGetThumbnails(urldecode($_GET['albumname']));
     break;
   case 'scan':
     handleGalleryScanning();
@@ -113,7 +113,7 @@ if ($_GET['operation']) {
     handleFilescan($_GET['cleanup']);
     break;
   case 'partial_create':
-    handlePartialCreate($_GET['path']);
+    handlePartialCreate(urldecode($_GET['path']));
     break;
   case 'store_settings':
     handleStoreSettings($_GET['root'], $_GET['order']);
diff --git a/apps/gallery/js/albums.js b/apps/gallery/js/albums.js
index 01e146a2f12c8bacdd10686cf0f70965c0b1fdf3..987412f28e0f0dbe2203bc845a5644ff46d3826f 100644
--- a/apps/gallery/js/albums.js
+++ b/apps/gallery/js/albums.js
@@ -54,12 +54,12 @@ Albums={
 		  event.preventDefault();
 		  galleryRemove(event.data.name);
     });
-	  $("a.view", local).attr('href','?view='+a.name);
+    $("a.view", local).attr('href','?view='+escape(a.name));
 	  $('h1',local).text(a.name);
 	  $(".gallery_album_cover", local).attr('title',a.name);
       $(".gallery_album_cover", local).css('background-repeat', 'no-repeat');
       $(".gallery_album_cover", local).css('background-position', '0');
-      $(".gallery_album_cover", local).css('background-image','url("ajax/galleryOp.php?operation=get_covers&albumname='+a.name+'")');
+      $(".gallery_album_cover", local).css('background-image','url("ajax/galleryOp.php?operation=get_covers&albumname='+escape(a.name)+'")');
       $(".gallery_album_cover", local).mousemove(function(e) {
 
         var albumMetadata = Albums.find(this.title);
diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php
index 167813a1a3157d4821e98c22409f849d06c51f5e..502237481a91aa93e2e59553034fc62907a1f05c 100644
--- a/apps/gallery/lib/album.php
+++ b/apps/gallery/lib/album.php
@@ -54,7 +54,6 @@ class OC_Gallery_Album {
   public static function removeByPath($path, $owner) {
     $album = self::find($owner, null, $path);
     $album = $album->fetchRow();
-    error_log($path . '--' . $album['album_name']);
     self::remove($owner, $album['album_name']);
     OC_Gallery_Photo::removeByAlbumId($album['album_id']);
     // find and remove any gallery which might be stored lower in dir hierarchy
diff --git a/apps/gallery/lib/scanner.php b/apps/gallery/lib/scanner.php
index dfb9edebfea864046bfc59f933b793bea4608fd1..2af63d8bf0eee3b6d78132a01b7b2d618781af3b 100644
--- a/apps/gallery/lib/scanner.php
+++ b/apps/gallery/lib/scanner.php
@@ -106,7 +106,7 @@ class OC_Gallery_Scanner {
       if (self::isPhoto($path.$file)) $addpath = TRUE;
     }
 
-    if ($addpath) $ret[] = $path;
+    if ($addpath) $ret[] = urlencode($path);
 
     return $ret;
   }