git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/8] builtin-mailinfo.c: compare character encodings case insensitively

From
Brandon Casey <casey@nrlssc.navy.mil>
Date
May 18, 2009, 23:44 UTC
Message-ID
<KfeKNR3Jm6YKvPIcYGBMpEj60b9ww0Dv2XSyNy2qLE-KEaaF8D8q9OHVC3tPAPSzNe1CJUXJDfA@cipher.nrlssc.navy.mil>
In-Reply-To
<KfeKNR3Jm6YKvPIcYGBMpLkRr97IFN82BZR2bJNHFQYwhjGgwGRoIAkKO5m1EZb7M9epcX8P-fk@cipher.nrlssc.navy.mil>

When converting between character encodings, git tests whether the "from" encoding and the "to" encoding have the same name. git should perform this test case insensitively so that e.g. utf-8 is not seen as a different encoding than UTF-8.

Additionally, it is not necessary to call tolower() anymore on the encodings extracted from the mail message.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 builtin-mailinfo.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c
index 5ebc8b5..c68187e 100644
--- a/builtin-mailinfo.c
+++ b/builtin-mailinfo.c
@@ -193,8 +193,7 @@ static void handle_content_type(struct strbuf *line)
 		*content_top = boundary;
 		boundary = NULL;
 	}
-	if (slurp_attr(line->buf, "charset=", &charset))
-		strbuf_tolower(&charset);
+	slurp_attr(line->buf, "charset=", &charset);
 
 	if (boundary) {
 		strbuf_release(boundary);
@@ -494,7 +493,7 @@ static void convert_to_utf8(struct strbuf *line, const char *charset)
 			return;
 	}
 
-	if (!strcmp(metainfo_charset, charset))
+	if (!strcasecmp(metainfo_charset, charset))
 		return;
 	out = reencode_string(line->buf, metainfo_charset, charset);
 	if (!out)
@@ -550,7 +549,6 @@ static int decode_header_bq(struct strbuf *it)
 		if (cp + 3 - it->buf > it->len)
 			goto decode_header_bq_out;
 		strbuf_add(&charset_q, ep, cp - ep);
-		strbuf_tolower(&charset_q);
 
 		encoding = cp[1];
 		if (!encoding || cp[2] != '?')
-- 
1.6.3.1.24.g152f4
Previous: Brandon CaseyNext: Brandon Casey
Message 4 of 9 in “character encoding portability updates”
  1. 0/8 character encoding portability updatesBrandon Casey, May 18, 2009
  2. 1/8 t3900: use ancient iconv names for backward compatibilityBrandon Casey, May 18, 2009
  3. 2/8 Use 'UTF-8' rather than 'utf-8' everywhere for backward compatibilityBrandon Casey, May 18, 2009
  4. 3/8 builtin-mailinfo.c: compare character encodings case insensitivelyBrandon Casey, May 18, 2009
  5. 4/8 builtin-mailinfo.c: use "ISO8859-1" instead of "latin1" as fallback encodingBrandon Casey, May 18, 2009
  6. 5/8 t3901: avoid negation on right hand side of '|'Brandon Casey, May 18, 2009
  7. 6/8 t3901: Use ISO8859-1 instead of ISO-8859-1 for backward compatibilityBrandon Casey, May 18, 2009
  8. 7/8 t9301: use ISO8859-1 rather than ISO-8859-1Brandon Casey, May 18, 2009
  9. 8/8 t5100: use ancient encoding syntax for backwards compatibilityBrandon Casey, May 18, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.