Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape multiline string #259

Closed
wants to merge 1 commit into from
Closed

Conversation

AyodeAwe
Copy link
Contributor

@AyodeAwe AyodeAwe commented Nov 6, 2024

Fixes a small issue with multiline strings passed to pr_body here.

Follow up PR to #257

@AyodeAwe AyodeAwe requested a review from a team as a code owner November 6, 2024 16:17
@AyodeAwe
Copy link
Contributor Author

AyodeAwe commented Nov 6, 2024

cc @KyleFromNVIDIA

Would love your review on this one since you reviewed #257

@AyodeAwe
Copy link
Contributor Author

AyodeAwe commented Nov 6, 2024

Closing this PR and opening one from my fork instead:

#260

@AyodeAwe AyodeAwe closed this Nov 6, 2024
Comment on lines +69 to +73
local flag="-R"
if [ "$2" = "stream" ]; then
flag="-sR"
fi
echo "$1" | jq ${flag} -c . | grep -E '^".*"$' | awk '{print substr($0, 2, length($0) - 2)}' && [ "${PIPESTATUS[2]}" -eq 0 ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no reason to differentiate between a single-line string and a multi-line string. The behavior is the same either way for a single-line string, and is an improvement for a multi-line string. Why not just treat it as multi-line unconditionally?

Suggested change
local flag="-R"
if [ "$2" = "stream" ]; then
flag="-sR"
fi
echo "$1" | jq ${flag} -c . | grep -E '^".*"$' | awk '{print substr($0, 2, length($0) - 2)}' && [ "${PIPESTATUS[2]}" -eq 0 ]
echo "$1" | jq -sR -c . | grep -E '^".*"$' | awk '{print substr($0, 2, length($0) - 2)}' && [ "${PIPESTATUS[2]}" -eq 0 ]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KyleFromNVIDIA left a comment here.

@@ -75,7 +79,7 @@ jobs:
echo "repo=$(escape_json "${REPO}")" >> $GITHUB_OUTPUT
echo "pr_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
echo "pr_title=$(escape_json "${PR_TITLE}")" >> $GITHUB_OUTPUT
echo "pr_body=$(escape_json "${PR_BODY}")" >> $GITHUB_OUTPUT
echo "pr_body=$(escape_json "${PR_BODY}" stream)" >> $GITHUB_OUTPUT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "pr_body=$(escape_json "${PR_BODY}" stream)" >> $GITHUB_OUTPUT
echo "pr_body=$(escape_json "${PR_BODY}")" >> $GITHUB_OUTPUT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants