From 1b442d11b416b736323d2e5c79d1fca897eaba6f Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Fri, 29 Sep 2017 21:33:31 +0300 Subject: [PATCH] Prevent projects from grabbing other projects' options. --- mesonbuild/interpreter.py | 3 +++ test cases/failing/61 getoption prefix/meson.build | 5 +++++ .../failing/61 getoption prefix/subprojects/abc/meson.build | 1 + .../61 getoption prefix/subprojects/abc/meson_options.txt | 1 + 4 files changed, 10 insertions(+) create mode 100644 test cases/failing/61 getoption prefix/meson.build create mode 100644 test cases/failing/61 getoption prefix/subprojects/abc/meson.build create mode 100644 test cases/failing/61 getoption prefix/subprojects/abc/meson_options.txt diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 8197b5e31..7641514d0 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')