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-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 415E91F5AE; Fri, 3 Jul 2020 21:58:26 +0000 (UTC) Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jrThQ-0003dr-LT; Fri, 03 Jul 2020 15:58:24 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1jrThL-0002Ab-ND; Fri, 03 Jul 2020 15:58:24 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Eric Wong Cc: meta@public-inbox.org Date: Fri, 03 Jul 2020 16:53:44 -0500 Message-ID: <87imf4qn87.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1jrThL-0002Ab-ND;;;mid=<87imf4qn87.fsf@x220.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/hgMhMBJ1flujZzHivaV8IsEzdGbnTyus= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: [PATCH] Import: Be more careful with names in email X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) List-Id: I recent encountered a nasty (in several sense of the word) from line: From: =?UTF-8?B?DQolLg0KSVwnbSBhIGhvcm55IGJyYXppbGlhbiBhbmQgSVwnbSBuZXcgaGVyZS4gSVwnbSBzZWFyY2hpbmcgZm9yIGEgZ3V5IHRvIGZ1Y2sgbWUgZnJvbSBiZWhpbmQgdGhpcyBldmVuaW5nLiBUZXh0IG1lIHNvb24gaHR0cDovL2NlbnRwZWFkb3RvdGFiLmNmL3JBbmdpZQ0KDQogJHB4Mm9ybTVuam1lDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0=?= 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" --- 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: # if (defined $name) { - $name =~ tr/<>//d; + $name =~ tr/\n\r<>$/ /d; 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; print $w "data ", (length($subject) + 1), "\n", $subject, "\n\n" or wfail; if ($tip ne '') { -- 2.20.1