diff --git a/.vale/templates/bot-comment-output.tmpl b/.vale/templates/bot-comment-output.tmpl index 4b1ae38871c1..dfa97978e17a 100644 --- a/.vale/templates/bot-comment-output.tmpl +++ b/.vale/templates/bot-comment-output.tmpl @@ -29,12 +29,7 @@ {{- /* Variables setup */ -}} {{- $loc := printf "%d" .Line -}} {{- $check := printf "%s" .Check -}} - {{- /* Escape special characters for valid JSON */ -}} - {{- $message := replace "\\" "\\\\" (printf "%s" .Message) -}} - {{- $message = replace "\"" "\\\"" $message -}} - {{- $message = replace "\n" "\\n" $message -}} - {{- $message = replace "\r" "\\r" $message -}} - {{- $message = replace "\t" "\\t" $message -}} + {{- $message := printf "%s" .Message -}} {{- /* Only add a link for RedHat rule errors */ -}} {{- $link := "" -}} {{- if contains "RedHat." .Check -}} diff --git a/scripts/prow-vale-review.sh b/scripts/prow-vale-review.sh index 4338b0ebf872..ef139b7917e6 100755 --- a/scripts/prow-vale-review.sh +++ b/scripts/prow-vale-review.sh @@ -23,19 +23,7 @@ function post_review_comment { BODY=$1 FILENAME=$2 echo "Sending review comment curl request..." - # Use jq to excruciatingly craft JSON payload - # jq -n because we're constructing from scratch per https://jqlang.org/manual/ - # --arg for string, --argjson for integer - # body constructed from https://docs.github.com/en/rest/pulls/comments?apiVersion=2022-11-28#create-a-review-comment-for-a-pull-request - payload=$(jq -n \ - --arg body "$BODY" \ - --arg commit_id "$COMMIT_ID" \ - --arg path "$FILENAME" \ - --argjson line "$LINE_NUMBER" \ - '{body: $body, commit_id: $commit_id, path: $path, line: $line, side: "RIGHT"}') - echo "DEBUG payload:" "$payload" - curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_AUTH_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/openshift/openshift-docs/pulls/$PULL_NUMBER/comments -d "$payload" - + curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_AUTH_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/openshift/openshift-docs/pulls/$PULL_NUMBER/comments -d '{"body":"'"$BODY"'","commit_id":"'"$COMMIT_ID"'","path":"'"$FILENAME"'","line":'"$LINE_NUMBER"',"side":"RIGHT"}' } function get_vale_errors {