Merge pull request 'Fix the problem with semicolon in the details' (#20) from fix_semicolon_in_details_problem into master

Reviewed-on: #20
This commit is contained in:
mgauthier 2024-11-15 15:24:35 +01:00
commit 87e21dccec

View file

@ -295,10 +295,13 @@ hook_db() {
}
hook_api() {
# Double quotes to single quotes and then wrap the whole message string in double quotes
API_DETAILS=$(echo "${MESSAGE}" | sed -e "s/\"/\'/g" -e 's/^/\"/g' -e 's/$/\"/g')
if [ "${VERBOSE}" = "1" ]; then
printf "\n********** API call **************\n"
printf "curl -f -s -S -X POST [REDACTED] -k -F api_key=[REDACTED] -F action=insertEvoMaintenance -F hostname=%s -F userid=%s -F ipaddress=%s -F begin_date=%s -F end_date='now()' -F details=%s" \
"${HOSTNAME}" "${USER}" "${IP}" "${BEGIN_DATE}" "${MESSAGE}"
"${HOSTNAME}" "${USER}" "${IP}" "${BEGIN_DATE}" "${API_DETAILS}"
printf "\n***********************************\n"
fi
@ -312,7 +315,7 @@ hook_api() {
-F ipaddress="${IP}" \
-F begin_date="${BEGIN_DATE}" \
-F end_date='now()' \
-F details="${MESSAGE}")
-F details="${API_DETAILS}")
# either cURL or the API backend can throw an error, otherwise it returns this JSON response
if [ "$API_RETURN_STATUS" = '{"status":"Ok"}' ]; then