zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Subject: Re: vcs_info: '%' in payloads not escaped
Date: Mon, 23 Jan 2017 11:04:32 +0000	[thread overview]
Message-ID: <20170123110432.GA7109@fujitsu.shahaf.local2> (raw)
In-Reply-To: <170106092711.ZM7535@torch.brasslantern.com>

Coming back to this thread...

Bart Schaefer wrote on Fri, Jan 06, 2017 at 09:27:11 -0800:
> I'm not very familiar with VCS_info.  Frank seemed concerned that the
> same variable might contain substrings both from git output that
> had one set of quoting needs and also from other sources that had
> another set of quoting needs.

That's exactly what happens.

The code flow is:

     1	if gen-applied-string hook is active:
     2	    applied_string=$(what the hook returns)
     3	else:
     4	    applied_string="literal value from the VCS"
     5	
     6	if set-patch-format hook is active:
     7	    hook_com[applied]=$applied_string
     8	    percent_m=$(what the hook returns)
     9	else:
    10	    percent_m=$(zformat ... p:${applied_string})
    11	
    12	VCS_INFO_formats … $percent_m

The catch is that both hooks have access to $applied_string, and either
of them might %-escape it and added prompt sequences (e.g., for
coloring) around it.  That is: once gen-applied-string has run, we don't
know whether it has already %-escaped the string it returns, and by
extension we don't know whether set-patch-format expects its
${hook_com[applied]} input to be literal or %-escaped.

So perhaps what we _can_ do is:

1) If *neither* hook was called, have vcs_info itself perform %-escaping
appropriately.  (That is: perform escaping on line 7 iff line 4 was
taken.)

2) Document that if *either* hook is registered, then handling
%-escaping is up to the user.

Would that address everyone's concerns?

Cheers,

Daniel
(optimizing for backwards compatibility)


  reply	other threads:[~2017-01-23 11:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-27 15:05 Daniel Shahaf
2016-12-27 15:13 ` Daniel Shahaf
2017-01-05 16:07 ` Daniel Shahaf
2017-01-05 16:27   ` Frank Terbeck
2017-01-06  2:21     ` Daniel Shahaf
2017-01-06 10:41       ` Frank Terbeck
2017-01-06 16:40         ` Daniel Shahaf
2017-01-06 17:27           ` Bart Schaefer
2017-01-23 11:04             ` Daniel Shahaf [this message]
2017-01-23 18:54               ` Frank Terbeck
2017-02-05  8:28                 ` [PATCH] vcs_info: Escape '%' signs in payloads Daniel Shahaf
2017-02-07  8:57                   ` Daniel Shahaf
2017-01-06 15:55   ` vcs_info: '%' in payloads not escaped Bart Schaefer
2017-01-06 16:49     ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170123110432.GA7109@fujitsu.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).