1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-06-05 15:57:05 +00:00

cargo: fix version parsing when state=latest (#12064)

* fix(cargo): fix greedy regex in get_latest_published_version

Fixes #8949

* docs(cargo): add changelog fragment for #12064
This commit is contained in:
Alexei Znamensky 2026-05-17 20:24:03 +12:00 committed by GitHub
parent c2485ea57b
commit 9cba458e3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -196,7 +196,7 @@ class Cargo:
cmd = ["search", name, "--limit", "1"]
data, dummy = self._exec(cmd, True, False, False)
match = re.search(r'"(.+)"', data)
match = re.search(r"^" + re.escape(name) + r'\s*=\s*"([^"]+)"', data, re.MULTILINE)
if not match:
self.module.fail_json(msg=f"No published version for package {name} found")
return match.group(1)