Skip to content

Commit 9bf2b38

Browse files
committed
Escape PR title for JSON string
1 parent 77bd5bf commit 9bf2b38

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

.github/workflows/update-docs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ jobs:
5858
# Opened/reopened/updated PR: include PR author + title
5959
- name: "Construct JSON (for PR sync)"
6060
if: github.event_name == 'pull_request' && github.event.action != 'closed'
61+
# Escape double quotes in PR title, as it will be used in a JSON string.
6162
run: |
63+
escapedPrTitle=$(echo "${{ github.event.pull_request.title }}" | sed 's/"/\\"/g')
6264
payload=$(cat <<'HEREDOC'
6365
{
6466
"op": "put",
@@ -68,7 +70,7 @@ jobs:
6870
"commit-sha": "${{ github.event.pull_request.head.sha }}",
6971
"date": "${{ github.event.pull_request.updated_at }}",
7072
"pr-author": "${{ github.event.pull_request.user.login }}",
71-
"pr-title": "${{ github.event.pull_request.title }}"
73+
"pr-title": "$escapedPrTitle"
7274
}
7375
HEREDOC)
7476
echo "VAR=$payload"

0 commit comments

Comments
 (0)