devtool: reset: Escape command line input used in regular expression

Running, e.g., `devtool reset sdbus-c++` would result in the following
error:

  re.error: multiple repeat at position 35

This was due to the ++ in the recipe name, which would be treated as an
incorrect regular expression in _reset().

Use re.escape() to make sure all characters in the recipe name are
treated literally.

(From OE-Core rev: 6e73bd9b3e6d529752db93879f2c0ed53873dd1a)

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Peter Kjellerstedt
2025-03-19 00:25:39 +01:00
committed by Richard Purdie
parent 0e32e1cb26
commit c0f3bc79b3
4 changed files with 30 additions and 1 deletions

View File

@@ -1951,7 +1951,7 @@ def _reset(recipes, no_clean, remove_work, config, basepath, workspace):
lines = f.readlines()
with open(new_layerconf_file, 'a') as nf:
for line in lines:
pprovider_exp = r'^PREFERRED_PROVIDER_.*? = "' + pn + r'"$'
pprovider_exp = r'^PREFERRED_PROVIDER_.*? = "' + re.escape(pn) + r'"$'
if not re.match(pprovider_exp, line):
nf.write(line)
else: