Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
vcs_info: '%' in payloads not escaped
- X-seq: zsh-workers 40240
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: vcs_info: '%' in payloads not escaped
- Date: Tue, 27 Dec 2016 15:05:07 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=Lq0pKwaN6l9LSer 3cxGdKgCxNjg=; b=2vb+PLXFVDm0nYjrKI9QSbtAF2TAgg1D/gER51SDYR6T58B T/DV1MtWllG8oKZBgNnVN3fjjK/MTKd55zbRwTimp75ajN+avngrVrLkY4WVg8eF OeaIseHHW/sOa0mBF9LE53DpnAH2+pBOVEIqv+c3E8YSL+NbgNXWIBs+zFcw=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=smtpout; bh=Lq0pKwaN6l9LSe r3cxGdKgCxNjg=; b=FahAKS9GfBp3QJbKJfFG90mQgFw1iuE4scpd29/yQDkdkp K+ONOQykTnh1R64IzgUVYznXhuMARC9NY3rGdq9R5h5n9dSWEHbAQtwBC78esnR+ /j7Db/h8bjSgh1jtGGAwcdc4Se2xXekorfI5qFARVe6n4opEmXXl/FyRCTEIk=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
To reproduce:
[[[
autoload vcs_info
vcs_info
precmd () {
vcs_info
print -Plr -- ${vcs_info_msg_0_} ${vcs_info_msg_1_}
}
zstyle ':vcs_info:*' formats ' (%s)-[%b]%u%c-' %m
zstyle ':vcs_info:*' actionformats ' (%s)-[%b|%a]%u%c-' %m
cd "$(mktemp -d)"
git init
echo foo > foo
git add foo
git commit -am import > /dev/null
git branch br
echo foo2 >> foo
git commit -am "left"
git checkout br
echo foo2b >> foo
git commit -am "%F{red} right"
git checkout --detach
git rebase master
]]]
At the end of the script, $vcs_info_msg_1_ is printed as
"6c0df9e1f8ebcdbeb94b08d906e068086ec76709 right (1 applied)"
with the "right (1 applied)" part in red.
This also happens after «hg branch "%F{red} foo"», etc..
I work around this hook by doing ${1//'%'/%%} in my gen-applied-string
hook. I assume vcs_info itself should be doing that, but I'm not sure
where in the code to add that. Is the following correct?
[[[
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
index e8c8e81..e9180b0 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
@@ -100,7 +100,7 @@ rrn=${bzrbase:t}
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat bzrbr || bzrbr="%b:%r"
hook_com=( branch "${bzrinfo[2]}" revision "${bzrinfo[1]}" )
if VCS_INFO_hook 'set-branch-format' "${bzrbr}"; then
- zformat -f bzrbr "${bzrbr}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
+ zformat -f bzrbr "${bzrbr}" "b:${hook_com[branch]//'%'/%%}" "r:${hook_com[revision]}"
else
bzrbr=${hook_com[branch-replace]}
fi
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index 4ec87c6..6272f69 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -149,7 +149,7 @@ VCS_INFO_git_handle_patches () {
hook_com=( applied "${git_applied_s}" unapplied "${git_patches_unapplied}"
applied-n ${#git_patches_applied} unapplied-n ${#git_patches_unapplied} all-n ${git_all} )
if VCS_INFO_hook 'set-patch-format' "${gitmsg}"; then
- zformat -f gitmisc "${gitmsg}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
+ zformat -f gitmisc "${gitmsg}" "p:${hook_com[applied]//'%'/%%}" "u:${hook_com[unapplied]//'%'/%%}" \
"n:${#git_patches_applied}" "c:${#git_patches_unapplied}" "a:${git_all}"
else
gitmisc=${hook_com[patch-replace]}
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index 69b7db3..8c902a7 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -113,7 +113,7 @@ hook_com=( branch "${r_branch}" revision "${r_lrev}" )
if VCS_INFO_hook 'set-branch-format' "${branchformat}"; then
zformat -f branchformat "${branchformat}" \
- "b:${hook_com[branch]}" "r:${hook_com[revision]}"
+ "b:${hook_com[branch]//'%'/%%}" "r:${hook_com[revision]}"
else
branchformat=${hook_com[branch-replace]}
fi
@@ -239,9 +239,9 @@ if zstyle -T ":vcs_info:${vcs}:${usercontext}:${rrn}" get-mq \
if VCS_INFO_hook 'set-patch-format' ${qstring}; then
zformat -f hgmqstring "${hgmqstring}" \
- "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
+ "p:${hook_com[applied]//'%'/%%}" "u:${hook_com[unapplied]//'%'/%%}" \
"n:${#mqpatches}" "c:${#mqunapplied}" "a:${#mqseries}" \
- "g:${hook_com[guards]}" "G:${#mqguards}"
+ "g:${hook_com[guards]//'%'/%%}" "G:${#mqguards}"
else
hgmqstring=${hook_com[patch-replace]}
fi
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 b/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4
index 3298849..c23f4f3 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4
@@ -20,7 +20,7 @@ change="${${$(${vcs_comm[cmd]} changes -m 1 ...\#have)##Change }%% *}"
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat p4branch || p4branch="%b:%r"
hook_com=( branch "${p4info[Client_name]}" revision "${change}" )
if VCS_INFO_hook 'set-branch-format' "${p4branch}"; then
- zformat -f p4branch "${p4branch}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
+ zformat -f p4branch "${p4branch}" "b:${hook_com[branch]//'%'/%%}" "r:${hook_com[revision]}"
else
p4branch=${hook_com[branch-replace]}
fi
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
index e1334f6..19affbd 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
@@ -52,7 +52,7 @@ rrn=${svnbase:t}
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r"
hook_com=( branch "${svninfo[URL]##*/}" revision "${cwdinfo[Revision]}" )
if VCS_INFO_hook 'set-branch-format' "${svnbranch}"; then
- zformat -f svnbranch "${svnbranch}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
+ zformat -f svnbranch "${svnbranch}" "b:${hook_com[branch]//'%'/%%}" "r:${hook_com[revision]}"
else
svnbranch=${hook_com[branch-replace]}
fi
diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt
index 4c61506..a39cd1a 100644
--- a/Functions/VCS_Info/VCS_INFO_quilt
+++ b/Functions/VCS_Info/VCS_INFO_quilt
@@ -197,7 +197,7 @@ function VCS_INFO_quilt() {
hook_com=( applied "${applied_string}" unapplied "${unapplied_string}"
applied-n ${#applied} unapplied-n ${#unapplied} all-n ${#all} )
if VCS_INFO_hook 'set-patch-format' ${qstring}; then
- zformat -f qstring "${qstring}" "p:${hook_com[applied]}" "u:${hook_com[unapplied]}" \
+ zformat -f qstring "${qstring}" "p:${hook_com[applied]//'%'/%%}" "u:${hook_com[unapplied]//'%'/%%}" \
"n:${#applied}" "c:${#unapplied}" "a:${#all}"
else
qstring=${hook_com[patch-replace]}
]]]
Messages sorted by:
Reverse Date,
Date,
Thread,
Author