From 9d290bd01251ec40deeeec6d914de0743cdfe353 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Fri, 24 Sep 2021 16:25:25 +0300 Subject: [PATCH] ci: correctly handle commit message with carriage returns in `payload-size.sh` (#43569) Previously, if a commit message contained a carriage return in its header, the `payload-size.sh` script would fail to upload the payload size data to Firebase, because the JSON payload would be messed up when trying to concatenate the commit message headers. See an example [here][1]. This commit avoids this problem by replacing carriage returns before concatenating the commit message headers with the JSON payload string. [1]: https://app.circleci.com/pipelines/github/angular/angular/37437/workflows/d0fa4adf-43bb-464e-a2fd-d87da15226dd PR Close #43569 --- scripts/ci/payload-size.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/payload-size.sh b/scripts/ci/payload-size.sh index f8da1958ced..f036834c63b 100644 --- a/scripts/ci/payload-size.sh +++ b/scripts/ci/payload-size.sh @@ -96,7 +96,7 @@ addMessage() { # because $CI_COMMIT_RANGE may contain the previous SHA which will not be in the # force push or commit, hence we default to last commit. message=$(git --git-dir ${PROJECT_ROOT}/.git log --oneline $commitRange -- || git --git-dir ${PROJECT_ROOT}/.git log --oneline -n1) - message=$(echo $message | sed 's/\\/\\\\/g' | sed 's/"/\\"/g') + message=$(echo $message | sed 's/\r//g' | sed 's/\\/\\\\/g' | sed 's/"/\\"/g') payloadData="$payloadData\"message\": \"$message\", " }