From 7e6aca581b67a7f6fa017745ab95ad0359184be1 Mon Sep 17 00:00:00 2001 From: martin Date: Sat, 13 Dec 2025 17:20:56 +0100 Subject: [PATCH] Sanitize message for Matrix notifications --- notify_templates/notify_matrix.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notify_templates/notify_matrix.sh b/notify_templates/notify_matrix.sh index efdf37d..ebea165 100644 --- a/notify_templates/notify_matrix.sh +++ b/notify_templates/notify_matrix.sh @@ -29,7 +29,7 @@ trigger_matrix_notification() { AccessToken="${!AccessTokenVar}" # e.g. MATRIX_ACCESS_TOKEN=token-value RoomId="${!RoomIdVar}" # e.g. MATRIX_ROOM_ID=myroom MatrixServer="${!MatrixServerVar}" # e.g. MATRIX_SERVER_URL=http://matrix.yourdomain.tld - MsgBody="{\"msgtype\":\"m.text\",\"body\":\"$MessageBody\"}" + MsgBody=$(jq -Rn --arg body "$MessageBody" '{msgtype:"m.text", body:$body}') # URL Example: https://matrix.org/_matrix/client/r0/rooms/!xxxxxx:example.com/send/m.room.message?access_token=xxxxxxxx curl -S -o /dev/null ${CurlArgs} -X POST "$MatrixServer/_matrix/client/r0/rooms/$RoomId/send/m.room.message?access_token=$AccessToken" -H 'Content-Type: application/json' -d "$MsgBody" @@ -37,4 +37,4 @@ trigger_matrix_notification() { if [[ $? -gt 0 ]]; then NotifyError=true fi -} \ No newline at end of file +}