mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-24 17:00:32 +02:00
40492: vcs_info: Escape '%' signs in payloads.
Test case: a patch whose subject is '%Sfoo%sbar'. ('S' and 's' are
expandos both in prompts and in the 'formats' style.)
This commit is contained in:
parent
e3bc63f00e
commit
ecd88284f3
6 changed files with 48 additions and 7 deletions
|
|
@ -202,6 +202,7 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
|
|||
|
||||
if VCS_INFO_hook 'gen-mqguards-string' "${mqguards[@]}"; then
|
||||
guards_string=${(j:,:)mqguards}
|
||||
# TODO: %-escape extra_zformats[g:...] value
|
||||
else
|
||||
guards_string=${hook_com[guards-string]}
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -18,12 +18,15 @@
|
|||
# - $hook_com is overwritten and the keys 'applied', 'applied-n',
|
||||
# 'unapplied', 'unapplied-n', 'all-n' are set.
|
||||
{
|
||||
local applied_needs_escaping='unknown'
|
||||
local unapplied_needs_escaping='unknown'
|
||||
if VCS_INFO_hook 'gen-applied-string' "${(@P)1}"; then
|
||||
if (( ${(P)#1} )); then
|
||||
REPLY=${(P)1[1]}
|
||||
else
|
||||
REPLY=""
|
||||
fi
|
||||
applied_needs_escaping='yes'
|
||||
else
|
||||
REPLY=${hook_com[applied-string]}
|
||||
fi
|
||||
|
|
@ -32,6 +35,7 @@
|
|||
|
||||
if VCS_INFO_hook 'gen-unapplied-string' "${(@P)3}"; then
|
||||
REPLY=${(P)#3}
|
||||
unapplied_needs_escaping='yes'
|
||||
else
|
||||
REPLY=${hook_com[unapplied-string]}
|
||||
fi
|
||||
|
|
@ -54,12 +58,22 @@
|
|||
hook_com[all-n]=$(( ${hook_com[applied-n]} + ${hook_com[unapplied-n]} ))
|
||||
hook_com+=( ${7:+"${(@kvP)7}"} )
|
||||
if VCS_INFO_hook 'set-patch-format' "${(P)6}"; then
|
||||
# Escape the value for use in $PS1
|
||||
if [[ $applied_needs_escaping == 'yes' ]]; then
|
||||
hook_com[applied]=${hook_com[applied]//'%'/%%}
|
||||
fi
|
||||
if [[ $unapplied_needs_escaping == 'yes' ]]; then
|
||||
hook_com[unapplied]=${hook_com[unapplied]//'%'/%%}
|
||||
fi
|
||||
|
||||
zformat -f REPLY "${(P)6}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
|
||||
"n:${hook_com[applied-n]}" "c:${hook_com[unapplied-n]}" \
|
||||
"a:${hook_com[all-n]}" \
|
||||
${8:+"${(@P)8}"}
|
||||
else
|
||||
unset applied_needs_escaping unapplied_needs_escaping # the hook deals with escaping
|
||||
REPLY=${hook_com[patch-replace]}
|
||||
fi
|
||||
hook_com=()
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue