diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php
index 3ddaf4446df59fda3bf0e30bf7295014f25becaf..3eb84ce1672b6270a14147876b7b32072c5abbd4 100644
--- a/apps/files_sharing/templates/public.php
+++ b/apps/files_sharing/templates/public.php
@@ -35,7 +35,7 @@
 			<?php else: ?>
 				<div id="imgframe">
 					<?php $size = \OC\Preview::isMimeSupported($_['mimetype']) ? 500 : 128 ?>
-					<img src="<?php p(OCP\Util::linkToRoute( 'core_ajax_public_preview', array('x' => $size, 'y' => $size, 'file' => urlencode($_['directory_path']), 't' => $_['dirToken']))); ?>" class="publicpreview"/>
+					<img src="<?php p(OCP\Util::linkToRoute( 'core_ajax_public_preview', array('x' => $size, 'y' => $size, 'file' => $_['directory_path'], 't' => $_['dirToken']))); ?>" class="publicpreview"/>
 				</div>
 			<?php endif; ?>
 			<div class="directDownload">
diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php
index 7544980e0719ccc39bb2b5aa14178b64c94d8c1d..9b7d578c9900731e3b62304b619a5227f1fde134 100644
--- a/apps/files_trashbin/lib/trashbin.php
+++ b/apps/files_trashbin/lib/trashbin.php
@@ -996,6 +996,6 @@ class Trashbin {
 	}
 
 	public static function preview_icon($path) {
-		return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path) ));
+		return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 36, 'y' => 36, 'file' => $path ));
 	}
 }