diff --git a/JsonPreprocessor/CJsonPreprocessor.py b/JsonPreprocessor/CJsonPreprocessor.py index df25e68..1fa2a04 100644 --- a/JsonPreprocessor/CJsonPreprocessor.py +++ b/JsonPreprocessor/CJsonPreprocessor.py @@ -1635,9 +1635,11 @@ def __isAscii(sInput : str) -> bool: elif '${' not in sInput and not regex.match(r'^\s*\[\s*import\s*\]\s*$', sInput.lower()): if not oKeyChecker.keyNameChecker(sInput) and __isAscii(sInput): errorMsg = oKeyChecker.errorMsg - elif regex.search(r'\[[^\'\[]+\'[^\']+\'\s*\]|\[\s*\'[^\']+\'[^\]]+\]', sInput) or\ - regex.search(r'\[[^\d\]]+\d+\]|\[\d+[^\d\]]+\]', sInput): + elif regex.search(r'\[[^\'\[]+\'[^\']+\'\s*\]|\[\s*\'[^\']+\'[^\]]+\]', sInput) or \ + regex.search(r'\[[^\d\[\]]+\d+\]|\[\d+[^\d\]]+\]', sInput): errorMsg = f"Invalid syntax: {sInput}" + if regex.search(r'\[\s*[\-\+]\d+\]', sInput): + errorMsg = f"Slicing is not supported (expression: '{sInput}')." elif regex.match(r'^\s*\${.+[\]}]*$', sInput): tmpInput = sInput while regex.search(r'\[[^\[\]]+\]', tmpInput): @@ -1651,6 +1653,8 @@ def __isAscii(sInput : str) -> bool: errorMsg = f"Invalid key name: {sInput} - This key name must be '{correctKey}'" elif sInput.count('${') != sInput.count('}') or sInput.count('[') != sInput.count(']'): errorMsg = f"Invalid key name: {sInput} - The brackets mismatch!!!" + elif regex.match(r'^\s*[^\$]+\${.+$|^\s*\${.+[^}\]]\s*$', sInput): + errorMsg = f"Invalid key name: '{sInput}'." elif regex.search(r'\${[^}]*}', sInput): if regex.search(r'\[\s*\]', sInput): errorMsg = f"Invalid key name: {sInput}. A pair of square brackets is empty!!!" @@ -2073,7 +2077,7 @@ def __handleLastElement(sInput : str) -> str: if i==iItems: item = __handleLastElement(item) elif not regex.match(r'^[\s{]*"[^"]*"\s*$', item): - item = regex.sub('(\$.+)\s*$', '"\\1" ', item) + item = regex.sub('^\s*([^\s].+[^\s])\s*$', '"\\1" ', item) while CNameMangling.STRINGVALUE.value in item: if "${" in tmpList[0]: sValue = tmpList.pop(0) diff --git a/JsonPreprocessor/JsonPreprocessor.pdf b/JsonPreprocessor/JsonPreprocessor.pdf index b90bb01..73c717a 100644 Binary files a/JsonPreprocessor/JsonPreprocessor.pdf and b/JsonPreprocessor/JsonPreprocessor.pdf differ diff --git a/JsonPreprocessor/version.py b/JsonPreprocessor/version.py index 5ceb649..4db8b79 100644 --- a/JsonPreprocessor/version.py +++ b/JsonPreprocessor/version.py @@ -18,6 +18,6 @@ # # Version and date of JsonPreprocessor # -VERSION = "0.9.1" -VERSION_DATE = "22.5.2025" +VERSION = "0.9.2" +VERSION_DATE = "5.6.2025" diff --git a/packagedoc/additional_docs/History.tex b/packagedoc/additional_docs/History.tex index a17e8bd..b3abae0 100644 --- a/packagedoc/additional_docs/History.tex +++ b/packagedoc/additional_docs/History.tex @@ -104,4 +104,8 @@ \historychange{- Enhanced cyclic import detection\newline - Fixed bugs and updated error messages} +\historyversiondate{0.9.2}{06/2025} +\historychange{- Improved invalid key name detection\newline +- Fixed bugs} + \end{packagehistory}