summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-09-29 21:33:31 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2017-09-29 21:33:31 +0300
commitcb9baae838cc07b768817c5bc0e0842a4481e9ab (patch)
tree3d7d2114325ca388f1055b02c601eb7fcd32ff9c
parentfd339759f20192ff9c464c112b27e402c7e42cbb (diff)
downloadmeson-optionsandbox.tar.gz
Prevent projects from grabbing other projects' options.optionsandbox
-rw-r--r--mesonbuild/interpreter.py3
-rw-r--r--test cases/failing/61 getoption prefix/meson.build5
-rw-r--r--test cases/failing/61 getoption prefix/subprojects/abc/meson.build1
-rw-r--r--test cases/failing/61 getoption prefix/subprojects/abc/meson_options.txt1
4 files changed, 10 insertions, 0 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 012370de2..92dd8cf03 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1700,6 +1700,9 @@ class Interpreter(InterpreterBase):
if len(args) != 1:
raise InterpreterException('Argument required for get_option.')
optname = args[0]
+ if ':' in optname:
+ raise InterpreterException('''Having a colon in option name is forbidden, projects are not allowed
+to directly access options of other subprojects.''')
try:
return self.environment.get_coredata().base_options[optname].value
except KeyError:
diff --git a/test cases/failing/61 getoption prefix/meson.build b/test cases/failing/61 getoption prefix/meson.build
new file mode 100644
index 000000000..8f85cff2a
--- /dev/null
+++ b/test cases/failing/61 getoption prefix/meson.build
@@ -0,0 +1,5 @@
+project('getopt prefix')
+
+subproject('abc')
+
+get_option('abc:foo')
diff --git a/test cases/failing/61 getoption prefix/subprojects/abc/meson.build b/test cases/failing/61 getoption prefix/subprojects/abc/meson.build
new file mode 100644
index 000000000..aa9c3df0f
--- /dev/null
+++ b/test cases/failing/61 getoption prefix/subprojects/abc/meson.build
@@ -0,0 +1 @@
+project('abc', 'c')
diff --git a/test cases/failing/61 getoption prefix/subprojects/abc/meson_options.txt b/test cases/failing/61 getoption prefix/subprojects/abc/meson_options.txt
new file mode 100644
index 000000000..89e624e24
--- /dev/null
+++ b/test cases/failing/61 getoption prefix/subprojects/abc/meson_options.txt
@@ -0,0 +1 @@
+option('foo', type : 'boolean')