diff --git a/installsystems/repository.py b/installsystems/repository.py
index b939875a66b3963b8911d4c4b460a832150a8956..066f9d64f486aee02de2263935e62a2fcc0455bb 100644
--- a/installsystems/repository.py
+++ b/installsystems/repository.py
@@ -7,6 +7,7 @@ Repository stuff
 '''
 
 import os
+import re
 import time
 import shutil
 import pwd
@@ -653,9 +654,18 @@ class RepositoryConfig(object):
     Repository configuration container
     '''
 
+    @staticmethod
+    def check_repository_name(name):
+        '''
+        Raise exception is repository name is invalid
+        '''
+        if re.match("^[-_\w]+$", name) is None:
+            raise Exception("Invalid repository name %s" % buf)
+        return name
+
     def __init__(self, name, **kwargs):
         # set default value for arguments
-        self.name = name
+        self.name = self.check_repository_name(name)
         self.path = ""
         self._offline = False
         self._dbpath = None