HMBXR5601-395 sanitise the commit comment for control characters

This commit is contained in:
Damian Smith 2018-08-14 12:56:58 +01:00
commit 9acab85d20

View file

@ -205,7 +205,8 @@ def gitAddCommitTagAll(versionNumber):
# Git commit
commitComment = versionNumber
if "COMMIT_COMMENT" in os.environ :
commitComment = commitComment + ' :: ' + os.environ["COMMIT_COMMENT"]
import unicodedata
commitComment = commitComment + ' :: ' + "".join(ch for ch in os.environ["COMMIT_COMMENT"] if unicodedata.category(ch)[0]!="C") # Cleans up non printable characters
print("git committing local repo: ", localRepoPath, " Comment: ", commitComment)
spout = subprocess.check_output([gitExecutable, "commit", "-a", "-m", commitComment], stderr = subprocess.STDOUT)
print("Result: ", spout.decode('utf-8'))