[Shell] fix(http): URL-encode message parameter
Message was not URL-encoded when sent (as "msg" URI parameter) which could cause issues with some messages (because of spaces). This commits uses cURL's "--data-urlencode" option for "msg" parameter so that cURL does the encoding for us. As a consequence, the script don't have to manually convert newlines (to $NEWLINE_CHAR) anymore: cURL also does that for us.
This commit is contained in:
parent
a47fed2080
commit
6b68de17e9
@ -6,7 +6,7 @@
|
|||||||
#
|
#
|
||||||
# Auteur: DUVERGIER Claude (http://claude.duvergier.fr)
|
# Auteur: DUVERGIER Claude (http://claude.duvergier.fr)
|
||||||
#
|
#
|
||||||
# Nécessite: sed, sh et wget
|
# Nécessite: sh et wget
|
||||||
#
|
#
|
||||||
# Possible usages: see usage_help()
|
# Possible usages: see usage_help()
|
||||||
|
|
||||||
@ -140,14 +140,6 @@ FINAL_MESSAGE_TO_SEND="${MESSAGE_HEADER}${MESSAGE_TO_SEND}${MESSAGE_FOOTER}"
|
|||||||
# echo "Will send the following to ${USER_LOGIN}:" #DEBUG
|
# echo "Will send the following to ${USER_LOGIN}:" #DEBUG
|
||||||
# echo "${FINAL_MESSAGE_TO_SEND}" #DEBUG
|
# echo "${FINAL_MESSAGE_TO_SEND}" #DEBUG
|
||||||
|
|
||||||
# Converts newlines to $NEWLINE_CHAR
|
|
||||||
FINAL_MESSAGE_TO_SEND=$(\
|
|
||||||
echo -n "${FINAL_MESSAGE_TO_SEND}" | \
|
|
||||||
sed '{:q;N;s/\n/'${NEWLINE_CHAR}'/g;t q}'\
|
|
||||||
)
|
|
||||||
# echo "Newline encoded message:" #DEBUG
|
|
||||||
# echo "${FINAL_MESSAGE_TO_SEND}" #DEBUG
|
|
||||||
|
|
||||||
# Particularités de l'appel de curl et la/les options associées :
|
# Particularités de l'appel de curl et la/les options associées :
|
||||||
# * Renvoi le code réponse HTTP uniquement :
|
# * Renvoi le code réponse HTTP uniquement :
|
||||||
# --write-out "%{http_code}" --silent --output /dev/null
|
# --write-out "%{http_code}" --silent --output /dev/null
|
||||||
@ -160,7 +152,7 @@ HTTP_STATUS_CODE=$(\
|
|||||||
--get "${SMSAPI_BASEURL}/${SMSAPI_SEND_ACTION}" \
|
--get "${SMSAPI_BASEURL}/${SMSAPI_SEND_ACTION}" \
|
||||||
--data "user=${USER_LOGIN}" \
|
--data "user=${USER_LOGIN}" \
|
||||||
--data "pass=${API_KEY}" \
|
--data "pass=${API_KEY}" \
|
||||||
--data "msg=${FINAL_MESSAGE_TO_SEND}" \
|
--data-urlencode "msg=${FINAL_MESSAGE_TO_SEND}" \
|
||||||
)
|
)
|
||||||
|
|
||||||
# Codes réponse HTTP possibles
|
# Codes réponse HTTP possibles
|
||||||
|
Loading…
Reference in New Issue
Block a user