diff --git a/core/Loader.php b/core/Loader.php
index b6d24e2b7bb26818f44333ac1830cc2c0aa906de..88b2c37585a28806691f8d7a566751f32047bc5c 100644
--- a/core/Loader.php
+++ b/core/Loader.php
@@ -25,9 +25,15 @@ class Piwik_Loader
 	 *
 	 * @param string $class Class name
 	 * @return string Class file name
+	 * @throws Exception if class name is invalid
 	 */
 	protected static function getClassFileName($class)
 	{
+		if(strspn($class, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_') !== strlen($class))
+		{
+			throw new Exception("Invalid class name \"$class\".");
+		}
+
 		$class = str_replace('_', '/', $class);
 
 		if($class == 'Piwik')