Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: vcs_info: '%' in payloads not escaped



Daniel Shahaf wrote on Tue, Dec 27, 2016 at 15:05:07 +0000:
> 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_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}"

So this breaks hooks that intentionally inject coloring sequences:

  +vi-git-applied-string() {
    hook_com[applied-string]="%F{yellow}$1%f"
    ret=1
  }

I suppose we could %-escape the patch subject before we call
applied-string, but then applied-string hooks that run «echo $1»
will suddenly get doubled percent signs in there.

Or maybe that's not a supported use of applied-string.

Not sure how to proceed.

Cheers,

Daniel



Messages sorted by: Reverse Date, Date, Thread, Author