Skip to content

First approach - use replaceSymbols on all branch names and only allo… #312

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions gitprompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,10 @@ function replaceSymbols() {
local VALUE=${1//_AHEAD_/${GIT_PROMPT_SYMBOLS_AHEAD}}
local VALUE1=${VALUE//_BEHIND_/${GIT_PROMPT_SYMBOLS_BEHIND}}
local VALUE2=${VALUE1//_NO_REMOTE_TRACKING_/${GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING}}
local VALUE3=${VALUE2//_PREHASH_/${GIT_PROMPT_SYMBOLS_PREHASH}}

echo ${VALUE2//_PREHASH_/${GIT_PROMPT_SYMBOLS_PREHASH}}
# Replace all but letters, numbers and forward slash to prevent shell exploit when rendering the branch name
echo ${VALUE3//[^a-z0-9\/]/}

# reenable globbing symbols
set +f
Expand Down Expand Up @@ -496,7 +498,7 @@ function updatePrompt() {
unset GIT_REMOTE
fi

local GIT_UPSTREAM="${git_status_fields[2]}"
local GIT_UPSTREAM="$(replaceSymbols ${git_status_fields[2]})"
if [[ -z "${__GIT_PROMPT_SHOW_UPSTREAM}" || "^" == "$GIT_UPSTREAM" ]]; then
unset GIT_UPSTREAM
else
Expand Down