Skip to content

Commit

Permalink
Enhancement 206 - Fix urgent issue of parameter name check
Browse files Browse the repository at this point in the history
  • Loading branch information
namsonx committed Oct 17, 2024
1 parent 775d099 commit 32e70f3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions JsonPreprocessor/CJsonPreprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1332,15 +1332,14 @@ def __keyNameValidation(self, sInput):
*No return value*
"""
checkPattern = re.compile(re.escape(self.specialCharacters))
errorMsg = ''
if CNameMangling.STRINGCONVERT.value in sInput:
sInput = sInput.replace(CNameMangling.STRINGCONVERT.value, '')
errorMsg = f"A substitution in key names is not allowed! Please update the key name {sInput}"
elif '${' not in sInput and not re.match(r'^\s*"\[\s*import\s*\]"\s*$', sInput.lower()):
if re.match(r'^[\s"]*[\+\-\*:@' + re.escape(self.specialCharacters) + ']+.*$', sInput):
errorMsg = f"Invalid key name: {sInput}. Key names have to start with a character, digit or underscore."
elif checkPattern.search(sInput):
elif re.search(rf'[{re.escape(self.specialCharacters)}]', sInput):
errorMsg = f"Invalid key name: {sInput}. Key names must not contain these special characters \"{self.specialCharacters}\" \
and have to start with a character, digit or underscore."
elif re.search(r'\${[^}]*}', sInput):
Expand All @@ -1360,7 +1359,7 @@ def __keyNameValidation(self, sInput):
elif re.search(r'^.+\[.+\]$', param[1].strip()):
errorMsg = f"Invalid syntax: Found index or sub-element inside curly brackets in the parameter '{sInput}'"
break
elif checkPattern.search(param[1]):
elif re.search(rf'[{re.escape(self.specialCharacters)}]', param[1]):
errorMsg = f"Invalid key name: '{param[1]}' in {sInput}. Key names must not contain these special characters \"{self.specialCharacters}\" \
and have to start with a character, digit or underscore."
break
Expand Down

0 comments on commit 32e70f3

Please sign in to comment.