From a7cf241334e3a76317b843b83991d7b1d50118b9 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 2 Sep 2016 17:00:58 -0400 Subject: [PATCH] Fix validation of man page extension. (#749) If the extension does not exist or is not a number, the error message is not raised because the assumptions cause a different exception. --- mesonbuild/interpreter.py | 5 ++++- test cases/failing/31 invalid man extension/meson.build | 2 ++ test cases/failing/32 no man extension/meson.build | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test cases/failing/31 invalid man extension/meson.build create mode 100644 test cases/failing/32 no man extension/meson.build diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index abbeaf724..ad381b6d9 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -454,7 +454,10 @@ class Man(InterpreterObject): def validate_sources(self): for s in self.sources: - num = int(s.split('.')[-1]) + try: + num = int(s.split('.')[-1]) + except (IndexError, ValueError): + num = 0 if num < 1 or num > 8: raise InvalidArguments('Man file must have a file extension of a number between 1 and 8') diff --git a/test cases/failing/31 invalid man extension/meson.build b/test cases/failing/31 invalid man extension/meson.build new file mode 100644 index 000000000..45eddca40 --- /dev/null +++ b/test cases/failing/31 invalid man extension/meson.build @@ -0,0 +1,2 @@ +project('man install', 'c') +m1 = install_man('foo.a1') diff --git a/test cases/failing/32 no man extension/meson.build b/test cases/failing/32 no man extension/meson.build new file mode 100644 index 000000000..bf835713f --- /dev/null +++ b/test cases/failing/32 no man extension/meson.build @@ -0,0 +1,2 @@ +project('man install', 'c') +m1 = install_man('foo')