diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php
new file mode 100644
index 0000000000000000000000000000000000000000..e1ab560803dcb14f7324873a2ece76615448cab5
--- /dev/null
+++ b/apps/files/appinfo/routes.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+$this->create('download', 'download{file}')
+	->requirements(array('file' => '.*'))
+	->actionInclude('files/download.php');
+
diff --git a/lib/route.php b/lib/route.php
index 772446e56152c3056ef9472f92380f248ffe2200..ba9d1724d12e5d85530214e0bac249675a4f6886 100644
--- a/lib/route.php
+++ b/lib/route.php
@@ -64,4 +64,9 @@ class OC_Route extends Route {
 		$this->setDefault('action', $action);
 		return $this;
 	}
+
+	public function actionInclude($file) {
+		$function = create_function('$param', 'unset($param["_route"]);$_GET=$param;unset($param);require_once "'.$file.'";');
+		$this->action($function);
+	}
 }
diff --git a/lib/search/provider/file.php b/lib/search/provider/file.php
index 21fae0c1ce541ee7d5e6b62859a7d6b77fdf0d48..e4e976ed7fdf21ac075098d821d1d032d55fa59a 100644
--- a/lib/search/provider/file.php
+++ b/lib/search/provider/file.php
@@ -10,12 +10,11 @@ class OC_Search_Provider_File extends OC_Search_Provider{
 
 			$name = basename($path);
 			$text = '';
-			$path = urlencode($path);
 			if($mime=='httpd/unix-directory') {
 				$link = OC_Helper::linkTo( 'files', 'index.php', array('dir' => $path));
 				$type = 'Files';
 			}else{
-				$link = OC_Helper::linkTo( 'files', 'download.php', array('file' => $path));
+				$link = OC_Helper::linkToRoute( 'download', array('file' => $path));
 				$mimeBase = $fileData['mimepart'];
 				switch($mimeBase) {
 					case 'audio':