aboutsummaryrefslogtreecommitdiff
path: root/optinterpreter.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2014-12-21 21:34:26 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2014-12-21 21:34:26 +0200
commit3630febe1e5d99250edf83d21e547cb58ae8dfea (patch)
tree53c308e963aa18f3ce2d3a0d86482ba68ea2d8f9 /optinterpreter.py
parenta337ab05e56ec47e5c90ab7302b9a5df58e469de (diff)
downloadmeson-3630febe1e5d99250edf83d21e547cb58ae8dfea.zip
meson-3630febe1e5d99250edf83d21e547cb58ae8dfea.tar.gz
meson-3630febe1e5d99250edf83d21e547cb58ae8dfea.tar.bz2
Verify that option names do not have invalid characters.
Diffstat (limited to 'optinterpreter.py')
-rw-r--r--optinterpreter.py8
1 files changed, 6 insertions, 2 deletions
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