From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 503 invoked by alias); 23 Jan 2017 11:08:19 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40398 Received: (qmail 5509 invoked from network); 23 Jan 2017 11:08:19 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-0.7/5.0):. Processed in 1.578362 secs); 23 Jan 2017 11:08:19 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= mesmtp; bh=xAO/zpx3P1Qv3BPhOOkA/ouAv7Q=; b=kypk4tQIeKhZM7XI0WW3r 7feB/u3FCQ9MObs6gcpzpufyTEIOtGMCBvKhx1C+HtSPZ+FTV0Wpry0pek9Qa/kI cnSN3vXQsunpgMVF1SOIcs04FavZG1CQlPz5KB9YGRLHvzKzYoOPk7oPo7iqx+FW SsVcDUup5b2QbSE/dJgDCU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= smtpout; bh=xAO/zpx3P1Qv3BPhOOkA/ouAv7Q=; b=d7CyNu4aVk9rvDVqCbHA Fje7ukn04Rsnd5lPo/kGo/UYQ/ceYIJp4tCOKrIpAro2oCkEwccR/jRjwBvNrp3J GPGYEAaKmOot0nTUxTxErAY9QH0P+YBLI6fjPsFv0XBSXAXIqsaUa+0pb6CCfD8U DmW0PkDxXzfECOuJcsxwpag= X-ME-Sender: X-Sasl-enc: H8B/mbxO1G8A5grR9aYvXQfaZlZwgtPU3UYvkqi7oq2o 1485169692 Date: Mon, 23 Jan 2017 11:04:32 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: vcs_info: '%' in payloads not escaped Message-ID: <20170123110432.GA7109@fujitsu.shahaf.local2> References: <20161227150507.GA20351@fujitsu.shahaf.local2> <20170105160730.GA21106@fujitsu.shahaf.local2> <871swhqxph.fsf@ft.bewatermyfriend.org> <20170106022128.GA6197@fujitsu.shahaf.local2> <87wpe8pj0o.fsf@ft.bewatermyfriend.org> <20170106164012.GB4948@fujitsu.shahaf.local2> <170106092711.ZM7535@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <170106092711.ZM7535@torch.brasslantern.com> User-Agent: Mutt/1.5.23 (2014-03-12) 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)