06fc5fb12900d7ee5821a5f20b47be2c4b894ac0

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

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.

Diff

 1diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh
 2index 971eb6540a786d74392c509b3b893f4f6ba0dd1f..e3f45ee993ca00579a94acbd69e5c1be97f21ca3 100644
 3--- a/plugins/dirhistory/dirhistory.plugin.zsh
 4+++ b/plugins/dirhistory/dirhistory.plugin.zsh
 5@@ -19,14 +19,14 @@ export DIRHISTORY_SIZE=30
 6 # Returns the element if the array was not empty,
 7 # otherwise returns empty string.
 8 function pop_past() {
 9-  eval "$1='$dirhistory_past[$#dirhistory_past]'"
10+  eval "$1=${(q)dirhistory_past[$#dirhistory_past]}"
11   if [[ $#dirhistory_past -gt 0 ]]; then
12     dirhistory_past[$#dirhistory_past]=()
13   fi
14 }
15 
16 function pop_future() {
17-  eval "$1='$dirhistory_future[$#dirhistory_future]'"
18+  eval "$1=${(q)dirhistory_future[$#dirhistory_future]}"
19   if [[ $#dirhistory_future -gt 0 ]]; then
20     dirhistory_future[$#dirhistory_future]=()
21   fi