All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] parse: Forbid ambiguous assignments to ${.}, ${+}, and ${:} variables
@ 2025-01-29 18:55 Nikolai Merinov
  2025-01-31 20:40 ` [bitbake-devel] " Peter Kjellerstedt
  2025-02-01 13:29 ` Richard Purdie
  0 siblings, 2 replies; 11+ messages in thread
From: Nikolai Merinov @ 2025-01-29 18:55 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Nikolai Merinov

Old code that parse variable names in assignment commands behave differntly for
variables that ends with special symbol for single-character variable names and
multi-character variable names. For example:

  A+="1"   # Change variable ${A}, '+' glued to '='
  A+ = "1" # Change variable ${A+}

  +="1"    # Change variable ${+}, the '+' symbol not part of assignment operator
  + = "1"  # Change variable ${+}

New code would always assume that '.=', '+=', and ':=' is assignment operator.
As result code like the following would raise parsing error

  +="value"

While code with extra spaces would work as before

  + = "value" # Change variable ${+}

This change allow to catch issues in code that generate bitbake configuration
files in a manner like "echo ${VARNAME}+=${VALUE} >> conf/local.conf"

Signed-off-by: Nikolai Merinov <n.merinov@inango-systems.com>
---
 lib/bb/parse/parse_py/ConfHandler.py                       | 2 +-
 lib/toaster/toastermain/management/commands/buildimport.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bb/parse/parse_py/ConfHandler.py b/lib/bb/parse/parse_py/ConfHandler.py
index 24f81f7e9..bdac66004 100644
--- a/lib/bb/parse/parse_py/ConfHandler.py
+++ b/lib/bb/parse/parse_py/ConfHandler.py
@@ -20,7 +20,7 @@ from bb.parse import ParseError, resolve_file, ast, logger, handle
 __config_regexp__  = re.compile( r"""
     ^
     (?P<exp>export\s+)?
-    (?P<var>[a-zA-Z0-9\-_+.${}/~:]+?)
+    (?P<var>([a-zA-Z0-9\-_${}/~] | [+.:](?!=))+?)
     (\[(?P<flag>[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@/]*)\])?
 
     \s* (
diff --git a/lib/toaster/toastermain/management/commands/buildimport.py b/lib/toaster/toastermain/management/commands/buildimport.py
index f7139aa04..37d27a445 100644
--- a/lib/toaster/toastermain/management/commands/buildimport.py
+++ b/lib/toaster/toastermain/management/commands/buildimport.py
@@ -60,7 +60,7 @@ def _log(msg):
 __config_regexp__  = re.compile( r"""
     ^
     (?P<exp>export\s+)?
-    (?P<var>[a-zA-Z0-9\-_+.${}/~]+?)
+    (?P<var>([a-zA-Z0-9\-_${}/~] | [.+](?!=))+?)
     (\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])?
 
     \s* (
-- 
2.34.1




^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-02-04 11:11 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-29 18:55 [PATCH] parse: Forbid ambiguous assignments to ${.}, ${+}, and ${:} variables Nikolai Merinov
2025-01-31 20:40 ` [bitbake-devel] " Peter Kjellerstedt
2025-02-03 17:42   ` Richard Purdie
2025-02-04 11:11   ` Nikolai Merinov
2025-02-01 13:29 ` Richard Purdie
2025-02-03 16:42   ` Nikolai Merinov
2025-02-03 17:40     ` Richard Purdie
2025-02-04  7:13       ` Nikolai Merinov
2025-02-04  7:13         ` [PATCH v3 1/1] " Nikolai Merinov
2025-02-03 16:42   ` [PATCH v2] " Nikolai Merinov
2025-02-03 17:39     ` Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.