summaryrefslogtreecommitdiff
path: root/git-send-email.perl
diff options
context:
space:
mode:
authorKrzysztof Mazur <krzysiek@podlesie.net>2012-10-24 21:08:26 (GMT)
committerJeff King <peff@peff.net>2012-10-25 10:05:35 (GMT)
commitce5478006c7318f12e6b2abeb0c0477009db63b5 (patch)
treeede8cfab80d6c1541dde1e9e7a499cf5ef3c5404 /git-send-email.perl
parent5637d8573206e8c3d99abacb6b6ca3cf11816202 (diff)
downloadgit-ce5478006c7318f12e6b2abeb0c0477009db63b5.zip
git-ce5478006c7318f12e6b2abeb0c0477009db63b5.tar.gz
git-ce5478006c7318f12e6b2abeb0c0477009db63b5.tar.bz2
git-send-email: introduce quote_subject()
The quote_rfc2047() always adds RFC2047 quoting. To avoid quoting ASCII subjects, before calling quote_rfc2047() subject must be tested for non-ASCII characters. This patch introduces a new quote_subject() function, which performs the test and calls quote_rfc2047 only if necessary. Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net> Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'git-send-email.perl')
-rwxr-xr-xgit-send-email.perl25
1 files changed, 19 insertions, 6 deletions
diff --git a/git-send-email.perl b/git-send-email.perl
index efeae4c..1574675 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -657,9 +657,7 @@ EOT
$initial_subject = $1;
my $subject = $initial_subject;
$_ = "Subject: " .
- ($subject =~ /[^[:ascii:]]/ ?
- quote_rfc2047($subject, $compose_encoding) :
- $subject) .
+ quote_subject($subject, $compose_encoding) .
"\n";
} elsif (/^In-Reply-To:\s*(.+)\s*$/i) {
$initial_reply_to = $1;
@@ -907,6 +905,22 @@ sub is_rfc2047_quoted {
$s =~ m/^(?:"[[:ascii:]]*"|=\?$token\?$token\?$encoded_text\?=)$/o;
}
+sub subject_needs_rfc2047_quoting {
+ my $s = shift;
+
+ return ($s =~ /[^[:ascii:]]/);
+}
+
+sub quote_subject {
+ local $subject = shift;
+ my $encoding = shift || 'UTF-8';
+
+ if (subject_needs_rfc2047_quoting($subject)) {
+ return quote_rfc2047($subject, $encoding);
+ }
+ return $subject;
+}
+
# use the simplest quoting being able to handle the recipient
sub sanitize_address {
my ($recipient) = @_;
@@ -1327,9 +1341,8 @@ foreach my $t (@files) {
$body_encoding = $auto_8bit_encoding;
}
- if ($broken_encoding{$t} && !is_rfc2047_quoted($subject) &&
- ($subject =~ /[^[:ascii:]]/)) {
- $subject = quote_rfc2047($subject, $auto_8bit_encoding);
+ if ($broken_encoding{$t} && !is_rfc2047_quoted($subject)) {
+ $subject = quote_subject($subject, $auto_8bit_encoding);
}
if (defined $author and $author ne $sender) {