1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-18 03:40:08 +00:00

fix(dirhistory): fix unsafe eval bug in back and forward widgets

The plugin unsafely processes directory paths in pop_past and pop_future.
This commit fixes that.
This commit is contained in:
Marc Cornellà 2021-11-09 15:05:53 +01:00
parent 6cb41b70a6
commit 06fc5fb129
No known key found for this signature in database
GPG key ID: 0314585E776A9C1B

View file

@ -19,14 +19,14 @@ export DIRHISTORY_SIZE=30
# Returns the element if the array was not empty,
# otherwise returns empty string.
function pop_past() {
eval "$1='$dirhistory_past[$#dirhistory_past]'"
eval "$1=${(q)dirhistory_past[$#dirhistory_past]}"
if [[ $#dirhistory_past -gt 0 ]]; then
dirhistory_past[$#dirhistory_past]=()
fi
}
function pop_future() {
eval "$1='$dirhistory_future[$#dirhistory_future]'"
eval "$1=${(q)dirhistory_future[$#dirhistory_future]}"
if [[ $#dirhistory_future -gt 0 ]]; then
dirhistory_future[$#dirhistory_future]=()
fi