From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23250 invoked by alias); 6 Jan 2017 02:24:50 -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: 40277 Received: (qmail 20879 invoked from network); 6 Jan 2017 02:24:50 -0000 X-Qmail-Scanner-Diagnostics: from out2-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.26):SA:0(-0.7/5.0):. Processed in 1.099634 secs); 06 Jan 2017 02:24:50 -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=cc: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=2nlB3V7dy81xuyhudTOq/nqu7EQ=; b=a5BkxaU329+ZmoVRwfDBr kkoQwpi8gLO9VUhzCQczp+gEJ4C9Slzfp8C8h9BZIyqclPv4q8wx3U+q8P2cxnVr dZKe8uu17H8/XiaE3oTJUMqNhw7pLB9MeAkBgf8VMNy0CemCWGMcNRsPpOFZYc0j 6op4CmOhtLDvJWzraGSXwE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=2nlB3V7dy81xuyhudTOq/nqu7EQ=; b=Y2hBC6oe0813iO4EwS0t 6tLh0vkBGjcRgPrhFt62VTL6o8zuw0Ca1GzUZ19bNKWQ7ymGfefMSRNPenLm1opU c+pOyNy9FwBMl6mVtinSz+s+43nf4XEgGEiA8EImt7Oi66LgwQ8xJ24AlexHyDlG 4lNcG5phhg5kvoXvJrN3R0Q= X-ME-Sender: X-Sasl-enc: oVrFDJno9YNLPPrCd1s8acxf/jEgMYu5GpYDRHQaWfD7 1483669482 Date: Fri, 6 Jan 2017 02:21:28 +0000 From: Daniel Shahaf To: Frank Terbeck Cc: zsh-workers@zsh.org Subject: Re: vcs_info: '%' in payloads not escaped Message-ID: <20170106022128.GA6197@fujitsu.shahaf.local2> References: <20161227150507.GA20351@fujitsu.shahaf.local2> <20170105160730.GA21106@fujitsu.shahaf.local2> <871swhqxph.fsf@ft.bewatermyfriend.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <871swhqxph.fsf@ft.bewatermyfriend.org> User-Agent: Mutt/1.5.23 (2014-03-12) Frank Terbeck wrote on Thu, Jan 05, 2017 at 17:27:06 +0100: > Hey Daniel! > > Daniel Shahaf wrote: > [...] > > How about the following? > > else > > git_applied_s="" > > fi > > + git_applied_s=${git_applied_s//'%'/%%} > > else > [...] > > git_patches_unapplied=${#git_patches_unapplied} > > + git_patches_unapplied=${git_patches_unapplied//'%'/%%} > > else > > I honestly don't know. Isn't this like kind-of-predictable behavior > versus a — potentially — a lot of special cases? I don't think that it's > possible to get this right in the general case. It's in-band data that > is indistinguishable from data that is interpreted by something that > interprets zsh's prompt language. A lot of special cases, how? $git_applied_s contains a string derived from git, so we know that any and all percent signs in it need escaping. That's why the escaping is done before the first zformat call, and only if user hooks were not called: because that's the only case in which we know for certain what does and doesn't need escaping. With this patch, the following invariant holds: immediately after the `fi` that ends the `if VCS_INFO_hook …` condition, $git_applied_s is properly %-escaped — either via the hook obeying the `Oddities' contract, or (if there's no hook) via the code added by this patch. I'm sure there's a way to escape payloads sanely, and we just need to figure out what that is... Cheers, Daniel