huskyCI
huskyCI copied to clipboard
Sanitize git authors email with invalid characters
Description
Some commits have authors with user.email in invalid format, including characters like \n causing eventual breaks in the json generation for reading by the API.
$ ./huskyci-client
[HUSKYCI][*] PRJ-staging -> [email protected]:prj/test.git
[HUSKYCI][*] huskyCI analysis started! 5917dde3-8fec-4279-bbbc-c74e216cb5c6
[HUSKYCI][ERROR] Monitoring analysis 5917dde3-8fec-4279-bbbc-c74e216cb5c6: huskyCI encountered an error trying to execute this analysis: invalid character '\n' in string literal
Proposed Changes
This PR proposes to sanitize the user.email so that the output is always a valid json. No break changes
Testing
$ i="user\/n\in;[email protected]"
$ jsonMiddle="\"${i//[^A-Za-z0-9_\.@-]/}\",$jsonMiddle"
$ echo "{\"authors\":[${jsonMiddle%?}]}"
{"authors":["[email protected]"]}
Thks @fguisso and @henriporto