Skip to content

Commit d481575

Browse files
committed
pass json as an encoding to avoid word-splitting errors
1 parent 5449a48 commit d481575

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

.github/workflows/zhook.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,20 @@ jobs:
7171
set -o pipefail
7272
set -o xtrace
7373
74+
# Base64 encode JSON to avoid whitespace issues in env file
75+
ENCODED_JSON=$(echo "${INPUT_EVENTJSON}" | base64 -w 0)
76+
7477
cat > /tmp/docker.env << EOF
75-
INPUT_ZITIID="${INPUT_ZITIID}"
76-
INPUT_WEBHOOKURL="${INPUT_WEBHOOKURL}"
77-
INPUT_EVENTJSON="${INPUT_EVENTJSON}"
78-
INPUT_SENDERUSERNAME="${INPUT_SENDERUSERNAME}"
79-
INPUT_SENDERICONURL="${INPUT_SENDERICONURL}"
80-
INPUT_ZITILOGLEVEL="${INPUT_ZITILOGLEVEL}"
81-
GITHUB_WORKSPACE="${GITHUB_WORKSPACE}"
78+
INPUT_ZITIID=${INPUT_ZITIID}
79+
INPUT_WEBHOOKURL=${INPUT_WEBHOOKURL}
80+
INPUT_EVENTJSON_B64=${ENCODED_JSON}
81+
INPUT_SENDERUSERNAME=${INPUT_SENDERUSERNAME}
82+
INPUT_SENDERICONURL=${INPUT_SENDERICONURL}
83+
INPUT_ZITILOGLEVEL=${INPUT_ZITILOGLEVEL}
84+
GITHUB_WORKSPACE=${GITHUB_WORKSPACE}
8285
EOF
8386
84-
# configure the kernel to write core dumps to the workspace directory that is writable by the container
87+
# configure the kernel to write core dumps to the workspace directory that is writable by the container in case there is a segfault valgrind cannot catch in a vgcore.%p
8588
sudo sysctl -w kernel.core_pattern="${GITHUB_WORKSPACE}/core.%e.%p.%t"
8689
8790
# build the action's container image so we can source it for the debug image

zhook.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import openziti
55
import json
66
import os
7+
import base64
78

89

910
class MattermostWebhookBody:
@@ -351,7 +352,17 @@ def dumpJson(self):
351352

352353
if __name__ == '__main__':
353354
url = os.getenv("INPUT_WEBHOOKURL")
354-
eventJsonStr = os.getenv("INPUT_EVENTJSON")
355+
356+
# Handle both base64-encoded and direct JSON input
357+
eventJsonB64 = os.getenv("INPUT_EVENTJSON_B64")
358+
if eventJsonB64:
359+
try:
360+
eventJsonStr = base64.b64decode(eventJsonB64).decode('utf-8')
361+
except Exception as e:
362+
print(f"Failed to decode base64 event JSON: {e}")
363+
eventJsonStr = os.getenv("INPUT_EVENTJSON")
364+
else:
365+
eventJsonStr = os.getenv("INPUT_EVENTJSON")
355366
username = os.getenv("INPUT_SENDERUSERNAME")
356367
icon = os.getenv("INPUT_SENDERICONURL")
357368
actionRepo = os.getenv("GITHUB_ACTION_REPOSITORY")

0 commit comments

Comments
 (0)