{"thread":{"id":"8968","subject":"[PATCH] send-email: extend sanitize_address_rfc822 to do rfc2047 quoting","startedAt":"2007-07-10T17:02:43Z","lastAt":"2007-07-11T12:49:28Z","messageCount":7,"participants":["Uwe Kleine-König","Sven Verdoolaege"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"46965","messageId":"11840869641759-git-send-email-ukleinek@informatik.uni-freiburg.de","threadId":"8968","inReplyTo":null,"subject":"[PATCH] send-email: extend sanitize_address_rfc822 to do rfc2047 quoting","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-07-10T17:02:43Z","receivedAt":"2007-07-10T17:02:43Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Without this patch I'm not able to properly send emails as I have a\nnon-ascii character in my name.\n\nSigned-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>\n---\nAs I'm not a perl profi, someone wants to check this code.\n\nActually this series is a test, as it is sended with the patched send-email.\n\nI hope it works :-)\n\nUwe\n\n git-send-email.perl |   24 +++++++++++++++++++-----\n 1 files changed, 19 insertions(+), 5 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 89f7c36..8b3d450 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -459,16 +459,30 @@ sub unquote_rfc2047 {\n \treturn \"$_\";\n }\n \n-# If an address contains a . in the name portion, the name must be quoted.\n+# If an address contains a non-ascii char in the name port, quote it according\n+# to rfc2047.\n+# If an address contains a . in the name portion, the name must be quoted using\n+# double quotes.\n sub sanitize_address_rfc822\n {\n \tmy ($recipient) = @_;\n-\tmy ($recipient_name) = ($recipient =~ /^(.*?)\\s+</);\n+\tmy ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)(\\s+<.*)/);\n+\n+\tif ($recipient_name && $recipient_name =~ /[^-a-zA-Z0-9!*+\\/ ]/ && $recipient_name !~ /=\\?utf-8\\?q?.*\\?=/) {\n+\t\t$recipient_name =~ s/([^-a-zA-Z0-9!*+ ])/sprintf(\"=%02X\", ord($1))/eg;\n+\t\t$recipient_name =~ s/ /_/;\n+\t\t$recipient_name =~ s/(.*)/=\\?utf-8\\?q\\?$1\\?=/;\n+\t}\n+\n \tif ($recipient_name && $recipient_name =~ /\\./ && $recipient_name !~ /^\".*\"$/) {\n-\t\tmy ($name, $addr) = ($recipient =~ /^(.*?)(\\s+<.*)/);\n-\t\t$recipient = \"\\\"$name\\\"$addr\";\n+\t\t$recipient_name = \"\\\"$recipient_name\\\"\";\n+\t}\n+\n+\tif ($recipient_name) {\n+\t\treturn \"$recipient_name$recipient_addr\";\n+\t} else {\n+\t\treturn \"$recipient\";\n \t}\n-\treturn $recipient;\n }\n \n sub send_message\n-- \n1.5.3.rc0.823.gdedbf\n"},{"id":"46966","messageId":"11840869671745-git-send-email-ukleinek@informatik.uni-freiburg.de","threadId":"8968","inReplyTo":"11840869641759-git-send-email-ukleinek@informatik.uni-freiburg.de","subject":"[PATCH] [RFC] send-email: honor --suppress-from --signed-off-cc","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-07-10T17:02:44Z","receivedAt":"2007-07-10T17:02:44Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"From: Uwe Kleine-KÃ¶nig <ukleinek@informatik.uni-freiburg.de>\n\n---\nNot sure, if this is how it should be.  Maybe we need another flag?\n\nBest regards\nUwe\n\n git-send-email.perl |    8 +++++---\n 1 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 8b3d450..a03153b 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -641,9 +641,11 @@ foreach my $t (@files) {\n \t\t\tif (/^(Signed-off-by|Cc): (.*)$/i && $signed_off_cc) {\n \t\t\t\tmy $c = $2;\n \t\t\t\tchomp $c;\n-\t\t\t\tpush @cc, $c;\n-\t\t\t\tprintf(\"(sob) Adding cc: %s from line '%s'\\n\",\n-\t\t\t\t\t$c, $_) unless $quiet;\n+\t\t\t\tif (!$suppress_from or $c eq $from) {\n+\t\t\t\t\tpush @cc, $c;\n+\t\t\t\t\tprintf(\"(sob) Adding cc: %s from line '%s'\\n\",\n+\t\t\t\t\t\t$c, $_) unless $quiet;\n+\t\t\t\t}\n \t\t\t}\n \t\t}\n \t}\n-- \n1.5.3.rc0.823.gdedbf\n"},{"id":"47010","messageId":"20070711075519.GB5815@informatik.uni-freiburg.de","threadId":"8968","inReplyTo":"11840869671745-git-send-email-ukleinek@informatik.uni-freiburg.de","subject":"Re: [PATCH] [RFC] send-email: honor --suppress-from --signed-off-cc","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-07-11T07:55:19Z","receivedAt":"2007-07-11T07:55:19Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello,\n\nplease forget that second patch, it was sent with a dirty send-email and\neven that was wrong.  The first patch however is IMHO a good one.\n\nI will look again into my issues with send-email probably next week.\n\nBest regards\nUwe\n\n-- \nUwe Kleine-König\n\nhttp://www.google.com/search?q=5%2B7\n"},{"id":"47016","messageId":"20070711084232.GE1528MdfPADPa@greensroom.kotnet.org","threadId":"8968","inReplyTo":"11840869641759-git-send-email-ukleinek@informatik.uni-freiburg.de","subject":"Re: [PATCH] send-email: extend sanitize_address_rfc822 to do rfc2047 quoting","fromName":"Sven Verdoolaege","fromEmail":"skimo@kotnet.org","sentAt":"2007-07-11T08:42:32Z","receivedAt":"2007-07-11T08:42:32Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"On Tue, Jul 10, 2007 at 07:02:43PM +0200, Uwe Kleine-König wrote:\n>  \tmy ($recipient) = @_;\n> -\tmy ($recipient_name) = ($recipient =~ /^(.*?)\\s+</);\n> +\tmy ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)(\\s+<.*)/);\n> +\n> +\tif ($recipient_name && $recipient_name =~ /[^-a-zA-Z0-9!*+\\/ ]/ && $recipient_name !~ /=\\?utf-8\\?q?.*\\?=/) {\n\nWhy the extra test for truthness of $recipient_name ?\n\n>  \tif ($recipient_name && $recipient_name =~ /\\./ && $recipient_name !~ /^\".*\"$/) {\n> -\t\tmy ($name, $addr) = ($recipient =~ /^(.*?)(\\s+<.*)/);\n> -\t\t$recipient = \"\\\"$name\\\"$addr\";\n> +\t\t$recipient_name = \"\\\"$recipient_name\\\"\";\n> +\t}\n> +\n> +\tif ($recipient_name) {\n> +\t\treturn \"$recipient_name$recipient_addr\";\n> +\t} else {\n> +\t\treturn \"$recipient\";\n>  \t}\n> -\treturn $recipient;\n\nWhy did you introduce interpolation just to get $recipient again?\nThen again, why do you need a test at all here?\n\n\treturn $recipient_name . $recipient_addr;\n\nshould work, no?\n\nskimo\n"},{"id":"47025","messageId":"20070711114909.GA14086@informatik.uni-freiburg.de","threadId":"8968","inReplyTo":"20070711084232.GE1528MdfPADPa@greensroom.kotnet.org","subject":"Re: [PATCH] send-email: extend sanitize_address_rfc822 to do rfc2047 quoting","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-07-11T11:49:09Z","receivedAt":"2007-07-11T11:49:09Z","isPatch":true,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Sven Verdoolaege wrote:\n> On Tue, Jul 10, 2007 at 07:02:43PM +0200, Uwe Kleine-König wrote:\n> >  \tmy ($recipient) = @_;\n> > -\tmy ($recipient_name) = ($recipient =~ /^(.*?)\\s+</);\n> > +\tmy ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)(\\s+<.*)/);\n> > +\n> > +\tif ($recipient_name && $recipient_name =~ /[^-a-zA-Z0-9!*+\\/ ]/ && $recipient_name !~ /=\\?utf-8\\?q?.*\\?=/) {\n> \n> Why the extra test for truthness of $recipient_name ?\nTry:\n\n\tmy $recipient = 'skimo@kotnet.org';\n\tmy ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)(\\s+<.*)/);\n\tprint \"Hoppla\\n\" if (!$recipient_name);\n\ni.e. if the pattern doesn't match, recipient_name is undefined.\n\nBut the function could be simplyfied anyhow.  e.g.\n\n\tif ($recipient_name) {\n\t\t... do all the quoting ...\n\t\treturn \"$recipient_name$recipient_addr\";\n\t} else {\n\t\treturn $recipient;\n\t}\n\nBest regards\nUwe\n\n-- \nUwe Kleine-König\n\nhttp://www.google.com/search?q=square+root+of+2\n"},{"id":"47026","messageId":"20070711120807.GH1528MdfPADPa@greensroom.kotnet.org","threadId":"8968","inReplyTo":"20070711114909.GA14086@informatik.uni-freiburg.de","subject":"Re: [PATCH] send-email: extend sanitize_address_rfc822 to do rfc2047 quoting","fromName":"Sven Verdoolaege","fromEmail":"skimo@kotnet.org","sentAt":"2007-07-11T12:08:07Z","receivedAt":"2007-07-11T12:08:07Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"On Wed, Jul 11, 2007 at 01:49:09PM +0200, Uwe Kleine-König wrote:\n> Sven Verdoolaege wrote:\n> > On Tue, Jul 10, 2007 at 07:02:43PM +0200, Uwe Kleine-König wrote:\n> > >  \tmy ($recipient) = @_;\n> > > -\tmy ($recipient_name) = ($recipient =~ /^(.*?)\\s+</);\n> > > +\tmy ($recipient_name, $recipient_addr) = ($recipient =~ /^(.*?)(\\s+<.*)/);\n> > > +\n> > > +\tif ($recipient_name && $recipient_name =~ /[^-a-zA-Z0-9!*+\\/ ]/ && $recipient_name !~ /=\\?utf-8\\?q?.*\\?=/) {\n> > \n> > Why the extra test for truthness of $recipient_name ?\n> \n> i.e. if the pattern doesn't match, recipient_name is undefined.\n\nI know.  I just didn't realize git-send-email was run with -w.\nSorry for the noise.\n\nskimo\n"},{"id":"47029","messageId":"20070711124928.GJ1528MdfPADPa@greensroom.kotnet.org","threadId":"8968","inReplyTo":"81b0412b0707110538s7eda05e8g6973e20fc4d91931@mail.gmail.com","subject":"Re: [PATCH] send-email: extend sanitize_address_rfc822 to do rfc2047 quoting","fromName":"Sven Verdoolaege","fromEmail":"skimo@kotnet.org","sentAt":"2007-07-11T12:49:28Z","receivedAt":"2007-07-11T12:49:28Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"On Wed, Jul 11, 2007 at 02:38:11PM +0200, Alex Riesen wrote:\n> On 7/11/07, Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de> wrote:\n> >Try:\n> >\n> >        my $recipient = 'skimo@kotnet.org';\n> >        my ($recipient_name, $recipient_addr) = ($recipient =~ \n> >        /^(.*?)(\\s+<.*)/);\n> >        print \"Hoppla\\n\" if (!$recipient_name);\n> \n> Still wrong. Try it on \"0 <0user@buildhost.localnet>\"\n\nI was going to suggest using defined($recipient_name) to make it clear,\nbut it won't affect correctness as \"0\" won't match the regexps in\nsanitize_address_rfc822 anyway.\n\nskimo\n"}]}