home · contact · privacy
Whitelist legal input characters.
authorChristian Heller <c.heller@plomlompom.de>
Sat, 5 Dec 2020 11:00:43 +0000 (12:00 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Sat, 5 Dec 2020 11:00:43 +0000 (12:00 +0100)
plomrogue/parser.py

index 69f728ee9859f3ed299f04b98177687c0ee52ce0..2820c186778365384be548929c2a1128f587d490 100644 (file)
@@ -78,6 +78,14 @@ class Parser:
 
         Respects function signature defined in function's .argtypes attribute.
         """
+        import string
+        msg = msg.rstrip()
+        legal_chars = string.digits + string.ascii_letters +\
+            string.punctuation + ' ' + 'ÄäÖöÜüߧ' + 'éèáàô'
+        for c in msg:
+            if not c in legal_chars:
+                raise ArgError('Command/message contains illegal character(s), '
+                               'may only contain ones of: %s' % legal_chars)
         tokens = self.tokenize(msg)
         if len(tokens) == 0:
             return None, ()