Add urlencoding for mongo_password
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
tobias 2024-06-19 12:08:41 +02:00
parent 8ceaf85ce0
commit 57601b133a

View File

@ -23,10 +23,30 @@ file_env() {
unset "$fileVar" unset "$fileVar"
} }
urlencode() {
raw="$1"
encoded=""
length=$(echo -n "$raw" | wc -c)
i=0
while [ $i -lt $length ]; do
c=$(echo "$raw" | cut -c $((i + 1)))
case "$c" in
[a-zA-Z0-9.~_-]) encoded="$encoded$c" ;;
*) encoded="$encoded$(printf '%%%02X' "'$c")" ;;
esac
i=$((i + 1))
done
echo "$encoded"
}
file_env "TOKEN" file_env "TOKEN"
file_env "MONGODB_PASSWORD" file_env "MONGODB_PASSWORD"
file_env "PAYLOAD_SECRET" file_env "PAYLOAD_SECRET"
export MONGODB_URI="mongodb://$MONGODB_USER:$MONGODB_PASSWORD@$MONGODB_HOST:$MONGODB_PORT" MONGODB_PASSWORD_ENCODED=$(urlencode "$MONGODB_PASSWORD")
export MONGODB_URI="mongodb://$MONGODB_USER:$MONGODB_PASSWORD_ENCODED@$MONGODB_HOST:$MONGODB_PORT"
"$@" "$@"