mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-29 04:53:17 +02:00
This patch adds missing % character escaping for custom git prompts used in a few themes. It also includes escaping for git-prompt.sh. In combination with CVE-2021-45444, this could allow code execution when displaying branch information in cloned malicious git repositories. However, zsh 5.8.1 and newer are largely the default zsh versions, and on those supported distributions with older zsh versions, the CVE has been found to be also patched. For this reason, this doesn't qualify as a security patch, but a bug fix for proper printing of git branches.
24 lines
896 B
Bash
24 lines
896 B
Bash
# RVM settings
|
|
if [[ -s ~/.rvm/scripts/rvm ]] ; then
|
|
RPS1="%{$fg[yellow]%}rvm:%{$reset_color%}%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt)%{$reset_color%} $EPS1"
|
|
else
|
|
if which rbenv &> /dev/null; then
|
|
RPS1="%{$fg[yellow]%}rbenv:%{$reset_color%}%{$fg[red]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$reset_color%} $EPS1"
|
|
fi
|
|
fi
|
|
|
|
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
|
|
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
|
|
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
|
|
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
|
|
|
# Customized git status, oh-my-zsh currently does not allow render dirty status before branch
|
|
git_custom_status() {
|
|
local cb=$(git_current_branch)
|
|
if [ -n "$cb" ]; then
|
|
cb="${cb//\%/%%}"
|
|
echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX${cb}$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
|
fi
|
|
}
|
|
|
|
PROMPT='$(git_custom_status)%{$fg[cyan]%}[%~% ]%{$reset_color%}%B$%b '
|