[PATCH] Default charset patch (bug 0000068)

Rune Saetre <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Hi again.

I think this patch should be applied before 1.4.1 is released.

I have submitted this before, but without the [PATCH] tag in the subject
line. And here it is again, since I cannot see it has been applied to the
CVS.

This patches the gateway-1.4.0/gwlib/http.c file from the 1.4.0 version to
set ISO-8859-1 as charset for subtypes of "text" if no charset is
specified in the headers.

This is in accordance with RFC 2616, section 3.7.1.
It also adresses bug #0000068.
Moreover, wapbox is totally useless without it here in Norway...

Regards
Rune

---
Rune Sætre <[email protected]>
NetCom as, Infrastruktur
Telefon (mob): 934 34 285
..
kannel140_charset.patch (text/plain, 1.4 KB)
diff -uprN clean/gateway-1.4.0/gwlib/http.c fixed/gateway-1.4.0/gwlib/http.c
--- clean/gateway-1.4.0/gwlib/http.c	2004-08-11 18:41:29.000000000 +0200
+++ fixed/gateway-1.4.0/gwlib/http.c	2005-01-04 01:48:29.000000000 +0100
@@ -2928,15 +2928,21 @@ void http_header_get_content_type(List *
         semicolon = octstr_search_char(h, ';', 0);
         if (semicolon == -1) {
             *type = h;
-            *charset = octstr_create("");
+            if (octstr_ncompare(h, octstr_imm("text"), strlen("text")) == 0)
+                *charset = octstr_create("ISO-8859-1");
+            else
+                *charset = octstr_create("");
         } else {
             *charset = octstr_duplicate(h);
             octstr_delete(*charset, 0, semicolon + 1);
             octstr_strip_blanks(*charset);
             equals = octstr_search_char(*charset, '=', 0);
-            if (equals == -1)
-                octstr_truncate(*charset, 0);
-            else {
+            if (equals == -1) {
+                octstr_destroy(*charset);
+                if (octstr_ncompare(h, octstr_imm("text"), 
+                                    strlen("text")) == 0)
+                    *charset = octstr_create("ISO-8859-1");
+            } else {
                 octstr_delete(*charset, 0, equals + 1);
                 if (octstr_get_char(*charset, 0) == '"')
                     octstr_delete(*charset, 0, 1);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.