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.
44 lines
1.3 KiB
Bash
44 lines
1.3 KiB
Bash
# Color shortcuts
|
|
RED=$fg[red]
|
|
YELLOW=$fg[yellow]
|
|
GREEN=$fg[green]
|
|
WHITE=$fg[white]
|
|
BLUE=$fg[blue]
|
|
RED_BOLD=$fg_bold[red]
|
|
YELLOW_BOLD=$fg_bold[yellow]
|
|
GREEN_BOLD=$fg_bold[green]
|
|
WHITE_BOLD=$fg_bold[white]
|
|
BLUE_BOLD=$fg_bold[blue]
|
|
RESET_COLOR=$reset_color
|
|
|
|
# Format for git_prompt_info()
|
|
ZSH_THEME_GIT_PROMPT_PREFIX=""
|
|
ZSH_THEME_GIT_PROMPT_SUFFIX=""
|
|
|
|
# Format for parse_git_dirty()
|
|
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$RED%}(*)"
|
|
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
|
|
|
# Format for git_prompt_status()
|
|
ZSH_THEME_GIT_PROMPT_UNMERGED=" %{$RED%}unmerged"
|
|
ZSH_THEME_GIT_PROMPT_DELETED=" %{$RED%}deleted"
|
|
ZSH_THEME_GIT_PROMPT_RENAMED=" %{$YELLOW%}renamed"
|
|
ZSH_THEME_GIT_PROMPT_MODIFIED=" %{$YELLOW%}modified"
|
|
ZSH_THEME_GIT_PROMPT_ADDED=" %{$GREEN%}added"
|
|
ZSH_THEME_GIT_PROMPT_UNTRACKED=" %{$WHITE%}untracked"
|
|
|
|
# Format for git_prompt_ahead()
|
|
ZSH_THEME_GIT_PROMPT_AHEAD=" %{$RED%}(!)"
|
|
|
|
# Format for git_prompt_long_sha() and git_prompt_short_sha()
|
|
ZSH_THEME_GIT_PROMPT_SHA_BEFORE=" %{$WHITE%}[%{$YELLOW%}"
|
|
ZSH_THEME_GIT_PROMPT_SHA_AFTER="%{$WHITE%}]"
|
|
|
|
USER_COLOR=$GREEN_BOLD
|
|
[[ $UID -eq 0 ]] && USER_COLOR=$RED_BOLD
|
|
|
|
# Prompt format
|
|
PROMPT='
|
|
%{$USER_COLOR%}%n@%m%{$WHITE%}:%{$YELLOW%}%~%u$(parse_git_dirty)$(git_prompt_ahead)%{$RESET_COLOR%}
|
|
%{$BLUE%}>%{$RESET_COLOR%} '
|
|
RPROMPT='%{$GREEN_BOLD%}${$(git_current_branch)//\%/%%}$(git_prompt_short_sha)$(git_prompt_status)%{$RESET_COLOR%}'
|