[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#285363: apache: AddDefaultCharset might not work



Package: apache
Version: 1.3.33-2
Severity: normal

When using the latest version of 'apache' and 'php4' on sid,
something weird happens with the charset attribute in the headers
sent out by Apache.
I believe this is a double problem (in both Apache and PHP) but feel
free to reassign if you think this belongs to only one of the packages.

The PHP side:
No matter what combination of default_mimetype and default_charset is
given in php.ini, or empty values even, PHP will always output an empty
charset for me.
 "Content-type: text/html; charset="

The Apache side:
If such a statement is present, apache skips adding a charset (even if
requested) because it thinks it already has a charset appended to the
header.
The source has a FIXME about verification in this case, this is what I'm
trying to do here.

Note that the charset directive works fine for e.g. *.html files, so
it's certainly some PHP involvement. But I still think Apache should
override in this case.

A patch which fixes the issue is attached.
It's rather a patch proposal though - all I want is to get my pages in
utf-8 without writing a content-modifying proxy :)

Depending on the reply, I will open another report with the PHP package.

Josef

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: powerpc (ppc)
Kernel: Linux 2.6.9-powerpc
Locale: LANG=pt_BR, LC_CTYPE=pt_BR (charmap=ISO-8859-1)

Versions of packages apache depends on:
ii  apache-common               1.3.33-2     Support files for all Apache 
webse
ii  debconf                     1.4.39       Debian configuration management 
sy
ii  dpkg                        1.10.24      Package maintenance system for 
Deb
ii  libc6                       2.3.2.ds1-18 GNU C Library: Shared libraries 
an
ii  libdb4.2                    4.2.52-17    Berkeley v4.2 Database Libraries 
[
ii  libexpat1                   1.95.8-1     XML parsing C library - runtime 
li
ii  libmagic1                   4.10-3       File type determination library 
us
ii  logrotate                   3.7-2        Log rotation utility
ii  mime-support                3.28-1       MIME files 'mime.types' & 
'mailcap
ii  perl                        5.8.4-3      Larry Wall's Practical Extraction 

-- debconf information excluded
--- http_protocol.c.old	2004-12-12 20:38:25.300493184 +0100
+++ http_protocol.c	2004-12-12 20:48:09.746643864 +0100
@@ -82,6 +82,7 @@
 	NULL };
     char **pcset;
     core_dir_config *conf;
+    int addcharset = 1, addcharsetname = 1;
 
     conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
                                                    &core_module);
@@ -93,17 +94,22 @@
     }
 
     if (ap_strcasestr(type, "charset=") != NULL) {
-	/* already has parameter, do nothing */
-	/* XXX we don't check the validity */
-	;
+        if (*(ap_strcasestr(type, "charset=") + strlen("charset="))) {
+            /* already has parameter, do nothing */
+            /* XXX we don't check the validity */
+            addcharsetname = 0;
+	} else {
+            /* empty charset= statement */
+            addcharset = 0;
+        }
     }
-    else {
+    if (addcharsetname) {
     	/* see if it makes sense to add the charset. At present,
 	 * we only add it if the Content-type is one of needcset[]
 	 */
 	for (pcset = needcset; *pcset ; pcset++) {
 	    if (ap_strcasestr(type, *pcset) != NULL) {
-		type = ap_pstrcat(r->pool, type, "; charset=", 
+		type = ap_pstrcat(r->pool, type, (addcharset ? "; charset=" : ""), 
                                   conf->add_default_charset_name, NULL);
 		break;
 	    }

Reply to: