X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=plomrogue%2Fparser.py;h=22e90594be8313ab514d6d346ce1b87fa498188b;hb=3ac4bfc7722ec4366698ae17f5e2006e6a9e8b30;hp=69f728ee9859f3ed299f04b98177687c0ee52ce0;hpb=e5a83f8987647c3c239e48d5bc1ff939ce531544;p=plomrogue2 diff --git a/plomrogue/parser.py b/plomrogue/parser.py index 69f728e..22e9059 100644 --- a/plomrogue/parser.py +++ b/plomrogue/parser.py @@ -77,7 +77,18 @@ class Parser: """Parse msg as call to function, return function with args tuple. Respects function signature defined in function's .argtypes attribute. + + Throws out messages with any but a small list of acceptable characters. + """ + import string + msg = msg.replace('\n', ' ') # Inserted by some tablet keyboards. + 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, ()