Req #75922 [Opn]: default_charset cannot be disabled in Content-Type
| From: | requinix@php.net | Date: | Tue, 06 Feb 2018 10:24:46 +0000 |
| Subject: | Req #75922 [Opn]: default_charset cannot be disabled in Content-Type | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213832@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75922&edit=1
ID: 75922
Updated by: requinix@php.net
Reported by: bugs at jth dot net
Summary: default_charset cannot be disabled in Content-Type
Status: Open
Type: Feature/Change Request
Package: PHP options/info functions
Operating System: Linux
PHP Version: 7.1.14
Block user comment: N
Private report: N
New Comment:
> You are in no position to require that users should use a single character set in PHP.
Please don't put words in my mouth. All I asked was why they had PHP configured to use one
default_charset (if not UTF-8 by default) but were serving HTML documents in another charset. With a
database, PHP, and the browser, all it takes is one incorrect character encoding setting or practice
to create headaches that can last for years.
Besides the "nuisance" call to header() you already know about, setting default_charset
empty is currently the only way I see to prevent adding the charset= to the Content-Type. I
don't know the exact reasons for why it's not recommended to have it empty, but I am sure
that setting default_charset to the charset in use is a good idea. And it certainly does not have to
be set to the same value for all requests to a server, let alone the same for all users.
I still don't see a good reason for why this behavior should be (optionally) disabled but
I'll leave this open.
> yes, it is a bug in ATS
Precisely. Someone over there forgot that Content-Types can specify media type parameters
https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7
Omitting the charset= in the header would be a workaround; fixing the tool to be aware of the
structure of a Content-Type header so that it could match the media type properly would be the
solution.
Previous Comments:
------------------------------------------------------------------------
[2018-02-06 10:09:53] spam2 at rhsoft dot net
> Having default_charset not match the actual charset used is a recipe for disaster
that unasked header too!
https://github.com/apache/trafficserver/issues/2849
yes, it is a bug in ATS, but without the unasked charset in the content-ytpe header this issue would
not exist at all
------------------------------------------------------------------------
[2018-02-06 09:59:21] bugs at jth dot net
You are in no position to require that users should use a single character set in PHP. There are a
number of reasons why different charsets and languages should coexist on the same web server. It was
working perfectly fine in php5, but is now broken after upgrading to php7.
Apache2 httpd.conf
#
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default. To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
#AddDefaultCharset UTF-8
This is working by commenting out or specifying
AddDefaultCharset Off
There should be a similar option in PHP
I have experimented with
default_charset = ""
internal_encoding = "UTF-8"
which apparently is working, but I am not sure, especially not when the PHP documentation states
"Setting default_charset to an empty value is not recommended."
------------------------------------------------------------------------
[2018-02-06 09:31:48] requinix@php.net
Having default_charset not match the actual charset used is a recipe for disaster. Why aren't
they changing that?
------------------------------------------------------------------------
[2018-02-06 09:16:40] bugs at jth dot net
Description:
------------
default_charset in php7 is now a mess being used in two different contexts. It should be two
different options: one for internal encoding and one for enabling/disabling being output in the
Content-Type: header.
The Content-Type: header is overriding the meta tag in the document, which different users are
creating in different charsets using the meta tag.
php is often used for simple functions not involving or regardless of the charset
e.g. database functions.
It is a nuisance and prone to error having the users to specify the charset both as an unnecessary
header() call and as a meta tag.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75922&edit=1