diff options
-rw-r--r-- | interpreter.py | 2 | ||||
-rw-r--r-- | optinterpreter.py | 8 | ||||
-rw-r--r-- | test cases/failing/14 invalid option name/meson.build | 1 | ||||
-rw-r--r-- | test cases/failing/14 invalid option name/meson_options.txt | 1 |
4 files changed, 9 insertions, 3 deletions
diff --git a/interpreter.py b/interpreter.py index d4f7be7..6c4f07e 100644 --- a/interpreter.py +++ b/interpreter.py @@ -935,7 +935,7 @@ class Interpreter(): if not isinstance(optname, str): raise InterpreterException('Argument of get_option must be a string.') if self.subproject != '': - optname = self.subproject + '-' + optname + optname = self.subproject + ':' + optname try: return self.environment.get_coredata().get_builtin_option(optname) except RuntimeError: diff --git a/optinterpreter.py b/optinterpreter.py index 59f5a9a..d30ddad 100644 --- a/optinterpreter.py +++ b/optinterpreter.py @@ -14,7 +14,7 @@ import mparser import coredata -import os +import os, re forbidden_option_names = {'type': True, 'strip': True, @@ -34,6 +34,8 @@ forbidden_option_names = {'type': True, class OptionException(coredata.MesonException): pass +optname_regex = re.compile('[^a-zA-Z0-9_-]') + class UserOption: def __init__(self, kwargs): super().__init__() @@ -166,10 +168,12 @@ class OptionInterpreter: opt_name = posargs[0] if not isinstance(opt_name, str): raise OptionException('Positional argument must be a string.') + if optname_regex.search(opt_name) is not None: + raise OptionException('Option names can only contain letters, numbers or dashes.') if opt_name in forbidden_option_names: raise OptionException('Option name %s is reserved.' % opt_name) if self.subproject != '': - opt_name = self.subproject + '-' + opt_name + opt_name = self.subproject + ':' + opt_name opt = option_types[opt_type](kwargs) if opt.description == '': opt.description = opt_name diff --git a/test cases/failing/14 invalid option name/meson.build b/test cases/failing/14 invalid option name/meson.build new file mode 100644 index 0000000..b99fd21 --- /dev/null +++ b/test cases/failing/14 invalid option name/meson.build @@ -0,0 +1 @@ +project('foo', 'c') diff --git a/test cases/failing/14 invalid option name/meson_options.txt b/test cases/failing/14 invalid option name/meson_options.txt new file mode 100644 index 0000000..c656402 --- /dev/null +++ b/test cases/failing/14 invalid option name/meson_options.txt @@ -0,0 +1 @@ +option('invalid/name', type : 'boolean', value : false)
\ No newline at end of file |