From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id BFB641F4D7 for ; Wed, 25 May 2022 21:43:02 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=pobox.com header.i=@pobox.com header.b="xg+E9qfm"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235808AbiEYVm5 (ORCPT ); Wed, 25 May 2022 17:42:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229811AbiEYVm4 (ORCPT ); Wed, 25 May 2022 17:42:56 -0400 Received: from pb-smtp2.pobox.com (pb-smtp2.pobox.com [64.147.108.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E47E92FE47 for ; Wed, 25 May 2022 14:42:54 -0700 (PDT) Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id F068D1305FE; Wed, 25 May 2022 17:42:53 -0400 (EDT) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=rBG/iAfWHVXhCd+FJ0i9+ojHWhQdAyQoJ+qz5A FNvL4=; b=xg+E9qfmKIj4IciU3f1WRqUboCM+E1y5EMeetruo4lfMszl+B1qsw2 h6yLImoyZn1ITIAwsZSX3BhnSy5YZBec4BwlZxuVXyhOFcUudWkhcmW4p+MhCWf7 qCYQzi92r+VN6wLnYjE9xdpOaBSMm6YStGWCro26SwBqYcHB8B00Q= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id E6ED11305FD; Wed, 25 May 2022 17:42:53 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.83.92.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 5FCE61305FC; Wed, 25 May 2022 17:42:53 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: "Johannes Schindelin via GitGitGadget" Cc: git@vger.kernel.org, =?utf-8?Q?Ren=C3=A9?= Scharfe , Taylor Blau , Derrick Stolee , Elijah Newren , rsbecker@nexbridge.com, =?utf-8?B?w4Z2YXIgQXJuZmo=?= =?utf-8?B?w7Zyw7A=?= Bjarmason , Johannes Schindelin Subject: Re: [PATCH v6 2/7] archive --add-virtual-file: allow paths containing colons References: <7eebcf27b45eb13541d4abae70a374a0e35ab6b8.1653145696.git.gitgitgadget@gmail.com> Date: Wed, 25 May 2022 14:42:52 -0700 In-Reply-To: (Junio C. Hamano's message of "Wed, 25 May 2022 13:22:24 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: A1B6CDFA-DC73-11EC-B3C5-CB998F0A682E-77302942!pb-smtp2.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Junio C Hamano writes: > But in _this_ particular case, the "defensive" measure necessary is > merely just to quote the shell variables properly, which nobody > sensible would say too onerous. I couldn't come up with anything > remotely plausible to fill "for such and such reasons" myself when I > tried to justify leaving the variables unquoted. > > Regardless of the quoting issue, we probably want to comment on what > value exactly is in PATHNAME before the assignment, by the way. > > E.g. > > # The PATHNAME variable holds a filename encoded like a > # string constant in C language (e.g. "\060" is digit "0") > if test_have_prereq FUNNYNAMES > then > PATHNAME=quoted:colon:\\060zero > else > PATHNAME=quoted\\060zero > fi > > That would not just protect only one aspect (i.e. we can pass a > colon into the resulting filename) this change but the path goes > through the c-unquoting rules. Actually, I _think_ that pushes us beyond the "reasonably defensive for the current need". We'd need to prepare how the pathname is expected to be unquoted for the later test test_path_is_file "$PATHNAME" to work. So here is what I queued as a fixup for this step on top of the series. t/t5003-archive-zip.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git c/t/t5003-archive-zip.sh w/t/t5003-archive-zip.sh index 3a5a052e8c..6addb6c684 100755 --- c/t/t5003-archive-zip.sh +++ w/t/t5003-archive-zip.sh @@ -209,19 +209,19 @@ check_added with_untracked untracked untracked test_expect_success UNZIP 'git archive --format=zip --add-virtual-file' ' if test_have_prereq FUNNYNAMES then - PATHNAME=quoted:colon + PATHNAME="pathname with : colon" else - PATHNAME=quoted + PATHNAME="pathname without colon" fi && git archive --format=zip >with_file_with_content.zip \ - --add-virtual-file=\"$PATHNAME\": \ + --add-virtual-file=\""$PATHNAME"\": \ --add-virtual-file=hello:world $EMPTY_TREE && test_when_finished "rm -rf tmp-unpack" && mkdir tmp-unpack && ( cd tmp-unpack && "$GIT_UNZIP" ../with_file_with_content.zip && test_path_is_file hello && - test_path_is_file $PATHNAME && + test_path_is_file "$PATHNAME" && test world = $(cat hello) ) '