From: ebiederm@xmission.com (Eric W. Biederman)
To: Eric Wong <e@yhbt.net>
Cc: meta@public-inbox.org
Subject: [PATCH] Import: Be more careful with names in email
Date: Fri, 03 Jul 2020 16:53:44 -0500 [thread overview]
Message-ID: <87imf4qn87.fsf@x220.int.ebiederm.org> (raw)
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;
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
next reply other threads:[~2020-07-03 21:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-03 21:53 Eric W. Biederman [this message]
2020-07-03 23:30 ` [PATCH] Import: Be more careful with names in email Eric Wong
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=87imf4qn87.fsf@x220.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=e@yhbt.net \
--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.
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).