diff options
| author | Eyal Itkin <eyal.itkin@gmail.com> | 2024-11-24 10:49:57 +0200 |
|---|---|---|
| committer | Xavier Claessens <xclaesse@gmail.com> | 2025-10-11 07:59:34 -0400 |
| commit | d2cf82b7a89d1b01cc2e29c1383d4e47e26c2b49 (patch) | |
| tree | 136b90f5e1817b5a210bea1d5c21f6ea6788fdc1 /mesonbuild/modules | |
| parent | b527ed534685f44069ee45a88b31cc55f2bd0780 (diff) | |
| download | meson-d2cf82b7a89d1b01cc2e29c1383d4e47e26c2b49.tar.gz | |
pkgconfig: Handle malformatted string dependencies
Add missing checks for correctness of string dependency, including
case for malformatted versioned dependency.
Resolves #13950.
Signed-off-by: Eyal Itkin <eyal.itkin@gmail.com>
Diffstat (limited to 'mesonbuild/modules')
| -rw-r--r-- | mesonbuild/modules/pkgconfig.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 8eb382b4c..1295cea50 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -299,11 +299,20 @@ class DependenciesHelper: self.version_reqs[name].update(version_reqs) def split_version_req(self, s: str) -> T.Tuple[str, T.Optional[str]]: + stripped_str = s.strip() + if not stripped_str: + raise mesonlib.MesonException(f'required dependency must not be empty, "{s}" was provided.') for op in ['>=', '<=', '!=', '==', '=', '>', '<']: - pos = s.find(op) - if pos > 0: - return s[0:pos].strip(), s[pos:].strip() - return s, None + pos = stripped_str.find(op) + if pos < 0: + continue + if pos == 0: + raise mesonlib.MesonException(f'required versioned dependency "{s}" is missing the dependency\'s name.') + stripped_str, version = stripped_str[0:pos].strip(), stripped_str[pos:].strip() + if not stripped_str: + raise mesonlib.MesonException(f'required versioned dependency "{s}" is missing the dependency\'s name.') + return stripped_str, version + return stripped_str, None def format_vreq(self, vreq: str) -> str: # vreq are '>=1.0' and pkgconfig wants '>= 1.0' |
