pleroma_ctl: Properly handle user arguments with whitespace
When user supplied arguments to pleroma_ctl include whitespace that has been properly quoted, all arguments were sent to ReleaseTasks in one string, which then String.split/1 the input on any whitespace. This broke Mix tasks that accept certain user input like instance gen and user management. To fix this, pleroma_ctl now sends the arguments in list form. Additionally pleroma_ctl arguments now need to be pre-processed. Fixes pleroma/pleroma#7874
This commit is contained in:
parent
209b9c0a1e
commit
7f97e21910
2 changed files with 25 additions and 4 deletions
|
|
@ -137,7 +137,11 @@ else
|
|||
SCRIPT=$(realpath "$0")
|
||||
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||
|
||||
FULL_ARGS="$*"
|
||||
# HACK: Script arguments need to be sent as an array to Mix tasks, otherwise they will break (quoted) arguments with whitespace.
|
||||
# Previously it was sent as string, which would get split on whitespace on the task side.
|
||||
# Escaping does not help including non-POSIX printf %q
|
||||
PREPARED_ARGS=""
|
||||
for arg in "$@"; do PREPARED_ARGS="$PREPARED_ARGS \"$arg\","; done
|
||||
|
||||
ACTION="$1"
|
||||
if [ $# -gt 0 ]; then
|
||||
|
|
@ -154,8 +158,8 @@ else
|
|||
if [ "$ACTION" = "update" ]; then
|
||||
update "$@"
|
||||
elif [ "$ACTION" = "migrate" ] || [ "$ACTION" = "rollback" ] || [ "$ACTION" = "create" ] || [ "$ACTION $SUBACTION" = "instance gen" ] || [ "$PLEROMA_CTL_RPC_DISABLED" = true ]; then
|
||||
"$SCRIPTPATH"/pleroma eval 'Pleroma.ReleaseTasks.run("'"$FULL_ARGS"'")'
|
||||
"$SCRIPTPATH"/pleroma eval 'Pleroma.ReleaseTasks.run(['"${PREPARED_ARGS%%,}"'])'
|
||||
else
|
||||
"$SCRIPTPATH"/pleroma rpc 'Pleroma.ReleaseTasks.run("'"$FULL_ARGS"'")'
|
||||
"$SCRIPTPATH"/pleroma rpc 'Pleroma.ReleaseTasks.run(['"${PREPARED_ARGS%%,}"'])'
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue