user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@yhbt.net>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: meta@public-inbox.org
Subject: Re: [PATCH] Import: Be more careful with names in email
Date: Fri, 3 Jul 2020 23:30:32 +0000	[thread overview]
Message-ID: <20200703233032.GA5810@dcvr> (raw)
In-Reply-To: <87imf4qn87.fsf@x220.int.ebiederm.org>

"Eric W. Biederman" <ebiederm@xmission.com> wrote:
> 
> I recent encountered a nasty (in several sense of the word) from line:
> 
> From: =?UTF-8?B?DQolLg0KSVwnbSBhIGhvcm55IGJyYXppbGlhbiBhbmQgSVwnbSBuZXcgaGVyZS4gSVwnbSBzZWFyY2hpbmcgZm9yIGEgZ3V5IHRvIGZ1Y2sgbWUgZnJvbSBiZWhpbmQgdGhpcyBldmVuaW5nLiBUZXh0IG1lIHNvb24gaHR0cDovL2NlbnRwZWFkb3RvdGFiLmNmL3JBbmdpZQ0KDQogJHB4Mm9ybTVuam1lDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0=?= <wordpress@practicalhomeschooler.com>
> 
> After extract_cmt_info was extracted and decoded the ``name'',
> passing that decoded ``name'' to git fast-import caused it
> to choke.  Something about a missing '>'.
> 
> To prevent this happening in the future transform a few more characters
> into spaces, and don't use string interpolation, use comma separated
> variables instead.
> 
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
> ---
> 
> I honestly don't know if I have closed all of the holes
> when implementing the code this way.  But this changes works for me(tm).
> Feel free to treat this as a bug report instead of a patch to apply.
> 
>  lib/PublicInbox/Import.pm | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
> index 66b359023bd2..df6c78368845 100644
> --- a/lib/PublicInbox/Import.pm
> +++ b/lib/PublicInbox/Import.pm
> @@ -310,7 +310,7 @@ sub extract_cmt_info ($;$) {
>  	# ref:
>  	# <CAD0k6qSUYANxbjjbE4jTW4EeVwOYgBD=bXkSu=akiYC_CB7Ffw@mail.gmail.com>
>  	if (defined $name) {
> -		$name =~ tr/<>//d;
> +		$name =~ tr/\n\r<>$/     /d;

Is getting rid of '$' an effort to avoid double interpolation by Perl?
Perl won't recursively expand variables AFAIK.

I agree with dropping \r and \n, though.

>  		utf8::encode($name);
>  	} else {
>  		$name = '';
> @@ -425,9 +425,10 @@ sub add {
>  		print $w "reset $ref\n" or wfail;
>  	}
>  
> -	print $w "commit $ref\nmark :$commit\n",
> -		"author $name <$email> $at\n",
> -		"committer $self->{ident} $ct\n" or wfail;
> +	# Be very careful with the strings from the email
> +	print $w "commit ", $ref, "\nmark :", $commit, "\n",
> +		"author ", $name, " <", $email, "> ", $at, "\n",
> +		"committer ", $self->{ident}, " ", $ct, "\n" or wfail;

I haven't tested, but I'm not seeing this hunk as necessary
once \r\n<> are removed.  Thanks.

  reply	other threads:[~2020-07-03 23:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03 21:53 [PATCH] Import: Be more careful with names in email Eric W. Biederman
2020-07-03 23:30 ` Eric Wong [this message]
2020-07-04 20:25   ` [PATCH] t/import: test for nasty characters Eric Wong
2020-07-04 20:28     ` Eric W. Biederman
2020-07-04 21:24       ` Eric Wong
2020-07-05 14:55       ` Leah Neukirchen

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: https://public-inbox.org/README

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

  git send-email \
    --in-reply-to=20200703233032.GA5810@dcvr \
    --to=e@yhbt.net \
    --cc=ebiederm@xmission.com \
    --cc=meta@public-inbox.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://80x24.org/public-inbox.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).