php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50167 default_charset not working correctly
Submitted: 2009-11-13 16:00 UTC Modified: 2009-11-14 15:49 UTC
From: oliviapurvis at yahoo dot com Assigned:
Status: Not a bug Package: Output Control
PHP Version: 5.3.0 OS: Centos 5.3
Private report: No CVE-ID: None
 [2009-11-13 16:00 UTC] oliviapurvis at yahoo dot com
Description:
------------
According to the PHP manual:
To disable sending of the charset, simply set default_charset to be empty.

I set it to empty but the http header always output:
Content-Type: text/html; charset=UTF-8

This inteferes with my html pages which has this html header:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Only occurs with PHP 5.3. Works correctly with 5.2.

By the way, if I set default_charset="iso-8859-1" it produces correctly:
Content-Type: text/html; charset=iso-8859-1

But what I want is to disable charset completely.





Reproduce code:
---------------
<?php
echo 'This is a test!';
exit;
?>

Expected result:
----------------
Transfer-Encoding: chunked
Content-Type: text/html

200 OK

Actual result:
--------------
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

200 OK

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-13 21:24 UTC] rasmus@php.net
Are you sure it isn't set by your Web server?  Apache has a default charset setting as well.

You should also be aware that it is extremely insecure to not set a charset on every response.  IE will end up guessing and that guess can be forced to something like UTF7 by the user by entering text that looks like UTF7.  That means that any input filtering you might have in place that assumes things are in iso-8859-1 or utf-8 will be completely ineffective.
 [2009-11-14 15:46 UTC] oliviapurvis at yahoo dot com
Oops, you're right. It was the apache "AddDefaultCharset UTF-8" directive that was causing this.

I upgraded both my Apache and PHP so didn't know which one causes this as the new apache RPM defaulted to UTF-8 while the previous one was off.

I wanted to disable the charset response because it was overriding whatever charset I put in the Meta tag of the HTML webpages.

Anyway, thanks.
 [2009-11-14 15:49 UTC] rasmus@php.net
not a bug then
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 22:01:28 2024 UTC