From: Junio C Hamano <gitster@pobox.com>
To: ZheNing Hu <adlternative@gmail.com>
Cc: ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com>,
Git List <git@vger.kernel.org>,
Christian Couder <christian.couder@gmail.com>,
Hariom Verma <hariom18599@gmail.com>,
Karthik Nayak <karthik.188@gmail.com>
Subject: Re: [PATCH 0/3] [GSOC][RFC] ref-filter: add contents:raw atom
Date: Wed, 26 May 2021 16:06:46 +0900 [thread overview]
Message-ID: <xmqqpmxeas8p.fsf@gitster.g> (raw)
In-Reply-To: <CAOLTT8ReZffY5gznSDD=Fgbt7YTtA5aJWX+f8Q8npcj0OwcuFQ@mail.gmail.com> (ZheNing Hu's message of "Wed, 26 May 2021 14:45:58 +0800")
ZheNing Hu <adlternative@gmail.com> writes:
> $ printf '%b' "name='a\\\0b\\\0c'\necho -e \"\$name\"" | sh | od -c
> 0000000 a \0 b \0 c \n
> 0000006
This is wrong. In the above, the variable name does not have a NUL
in it. It insead has 2-byte sequence "\" and "0" in it, and you are
letting "echo -e" to convert it into binary, which is not portable
at all.
I'd suggest instead to declare that some host languages, like shell,
are not binary-clean and either refuse to process atoms whose values
have NUL in them. Silently truncating strings at NUL or striping
NULs in strings are also acceptable options if clearly documented.
Claiming that we stuff binaries into variables of the host language,
while not doing so and instead assigning a quoted form, is not good.
I have not thought about Python3 very much. For the purpose of most
%(placeholders), it is vastly more preferrable to use str (i.e. text
sequence type) as opposed to bytes, as you do not have to .decode()
to use the resulting "string", but even for things like %(refname),
it is not technically kosher to assume that the contents are UTF-8
encoded text, as filenames used to represent refnames are merely a
sequence of bytes except NUL, but for consistency with binary gunk,
we might have to emit everything as bytes. I dunno.
> In shell or python2/3, we can replace'\0' with "\\0".
Not for shell. We should declare that it is not supported to feed
binary to shell.
next prev parent reply other threads:[~2021-05-26 7:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-23 9:53 [PATCH 0/3] [GSOC][RFC] ref-filter: add contents:raw atom ZheNing Hu via GitGitGadget
2021-05-23 9:53 ` [PATCH 1/3] [GSOC] quote: add *.quote_buf_with_size functions ZheNing Hu via GitGitGadget
2021-05-23 9:53 ` [PATCH 2/3] [GSOC] ref-filter: support %(contents) for blob, tree ZheNing Hu via GitGitGadget
2021-05-25 5:03 ` Junio C Hamano
2021-05-25 5:47 ` Junio C Hamano
2021-05-25 9:28 ` ZheNing Hu
2021-05-25 17:11 ` Junio C Hamano
2021-05-26 7:48 ` ZheNing Hu
2021-05-23 9:53 ` [PATCH 3/3] [GSOC] ref-filter: add contents:raw atom ZheNing Hu via GitGitGadget
2021-05-24 1:09 ` [PATCH 0/3] [GSOC][RFC] " Junio C Hamano
2021-05-24 2:41 ` Felipe Contreras
2021-05-24 5:22 ` Bagas Sanjaya
2021-05-24 15:21 ` Junio C Hamano
2021-05-24 13:09 ` ZheNing Hu
2021-05-26 0:56 ` Junio C Hamano
2021-05-26 6:45 ` ZheNing Hu
2021-05-26 7:06 ` Junio C Hamano [this message]
2021-05-26 9:17 ` ZheNing Hu
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqpmxeas8p.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=adlternative@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=hariom18599@gmail.com \
--cc=karthik.188@gmail.com \
/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://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).