From 4d37b5a0722a34ef2b640253c20edd078ab9f672 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 03:43:23 +0000 Subject: [PATCH 1/3] Initial plan From d4cca86047c4829945a382c3b3c70405dcf44418 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 03:57:38 +0000 Subject: [PATCH 2/3] Implement unified error for Python inline code on left-hand side of colon Co-authored-by: namsonx <14203622+namsonx@users.noreply.github.com> --- JsonPreprocessor/CJsonPreprocessor.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/JsonPreprocessor/CJsonPreprocessor.py b/JsonPreprocessor/CJsonPreprocessor.py index 4989acc..e250979 100644 --- a/JsonPreprocessor/CJsonPreprocessor.py +++ b/JsonPreprocessor/CJsonPreprocessor.py @@ -2148,6 +2148,20 @@ def __handleLastElement(sInput : str) -> str: self.__reset() raise Exception(f"{error} in line: '{line}'") line = line.rstrip() + # Check for Python inline code on left-hand side of colon (not allowed) + if '<<' in line or '>>' in line: + # Split line by colons to analyze key-value pairs + # If a Python inline code appears before the first colon of a key-value pair, it's invalid + colon_split = line.split(':', 1) # Split on first colon only + if len(colon_split) > 1 and regex.search(r'<<.*?>>', colon_split[0]): + # Check if this is actually a key (not just a value from previous line) + # Look for typical key patterns: "key", ${key}, etc. + key_part = colon_split[0].strip() + # Remove common prefixes like comma and whitespace + key_part = regex.sub(r'^[,\s]*', '', key_part) + if regex.search(r'<<.*?>>', key_part): + self.__reset() + raise Exception("Python inline code on the left-hand side of the colon is generally not allowed.") # Checks the syntax of the Python inline code if '<<' in line or '>>' in line: patterns = [ From 1da0761070f1de3782d3bc265cb80fa7922aa5a2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 03:59:51 +0000 Subject: [PATCH 3/3] Finalize Python inline code left-hand side restriction implementation Co-authored-by: namsonx <14203622+namsonx@users.noreply.github.com> --- JsonPreprocessor/CJsonPreprocessor.py | 29 +++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/JsonPreprocessor/CJsonPreprocessor.py b/JsonPreprocessor/CJsonPreprocessor.py index e250979..1cf0183 100644 --- a/JsonPreprocessor/CJsonPreprocessor.py +++ b/JsonPreprocessor/CJsonPreprocessor.py @@ -2149,19 +2149,22 @@ def __handleLastElement(sInput : str) -> str: raise Exception(f"{error} in line: '{line}'") line = line.rstrip() # Check for Python inline code on left-hand side of colon (not allowed) - if '<<' in line or '>>' in line: - # Split line by colons to analyze key-value pairs - # If a Python inline code appears before the first colon of a key-value pair, it's invalid - colon_split = line.split(':', 1) # Split on first colon only - if len(colon_split) > 1 and regex.search(r'<<.*?>>', colon_split[0]): - # Check if this is actually a key (not just a value from previous line) - # Look for typical key patterns: "key", ${key}, etc. - key_part = colon_split[0].strip() - # Remove common prefixes like comma and whitespace - key_part = regex.sub(r'^[,\s]*', '', key_part) - if regex.search(r'<<.*?>>', key_part): - self.__reset() - raise Exception("Python inline code on the left-hand side of the colon is generally not allowed.") + if '<<' in line and ':' in line: + # Check if any Python inline code pattern appears before any colon on the line + # This catches all forms: <<...>>, "<<...>>", ${<<...>>}, param[<<...>>], etc. + # Split by colon and check if left parts contain Python inline code + parts = line.split(':') + for i in range(len(parts) - 1): # All parts except the last could be key parts + left_part = parts[i] + if regex.search(r'<<.*?>>', left_part): + # Additional check: make sure this looks like a key part, not a value part + # Skip if this part seems to be continuing a previous value + stripped_left = left_part.strip() + # Simple heuristic: if it starts with a quote, comma, or common key patterns, it's likely a key + if (stripped_left.startswith(('"', "'", '${', ',')) or + regex.search(r'[{,]\s*[^,}]*$', stripped_left)): + self.__reset() + raise Exception("Python inline code on the left-hand side of the colon is generally not allowed.") # Checks the syntax of the Python inline code if '<<' in line or '>>' in line: patterns = [