Skip to content

Commit

Permalink
pkgconfig: Handle malformatted string dependencies
Browse files Browse the repository at this point in the history
Add missing checks for correctness of string dependency, including
case for malformatted versioned dependency.

Resolves #13950.

Signed-off-by: Eyal Itkin <[email protected]>
  • Loading branch information
Eyal Itkin committed Nov 24, 2024
1 parent 9f3f88f commit c59ba8f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions mesonbuild/modules/pkgconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,20 @@ def add_version_reqs(self, name: str, version_reqs: T.Optional[T.List[str]]) ->
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'
Expand Down

0 comments on commit c59ba8f

Please sign in to comment.