Skip to content

Commit 8d5c610

Browse files
committed
Remove AddDefaultCharset from the default configuration because
setting a site-wide default does more harm than good. PR: 23421 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@111581 13f79535-47bb-0310-9956-ffa450edef68
1 parent 637c27f commit 8d5c610

5 files changed

Lines changed: 33 additions & 37 deletions

File tree

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ Changes with Apache 2.1.3
22

33
[Remove entries to the current 2.0 section below, when backported]
44

5+
*) conf: Remove AddDefaultCharset from the default configuration because
6+
setting a site-wide default does more harm than good. PR 23421.
7+
[Roy Fielding]
8+
59
Changes with Apache 2.1.2
610

711
*) mod_proxy: Respect errors reported by pre_connection hooks.

docs/conf/httpd-std.conf.in

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -813,18 +813,6 @@ ServerSignature On
813813
</IfModule>
814814

815815
<IfModule mod_mime.c>
816-
#
817-
# Specify a default charset for all pages sent out. This is
818-
# always a good idea and opens the door for future internationalisation
819-
# of your web site, should you ever want it. Specifying it as
820-
# a default does little harm; as the standard dictates that a page
821-
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
822-
# are merely stating the obvious. There are also some security
823-
# reasons in browsers, related to javascript and URL parsing
824-
# which encourage you to always set a default char set.
825-
#
826-
AddDefaultCharset ISO-8859-1
827-
828816
#
829817
# Commonly used filename extensions to character sets. You probably
830818
# want to avoid clashes with the language extensions, unless you

docs/conf/httpd-win.conf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -758,18 +758,6 @@ LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt
758758
#
759759
ForceLanguagePriority Prefer Fallback
760760

761-
#
762-
# Specify a default charset for all pages sent out. This is
763-
# always a good idea and opens the door for future internationalisation
764-
# of your web site, should you ever want it. Specifying it as
765-
# a default does little harm; as the standard dictates that a page
766-
# is in iso-8859-1 (latin1) unless specified otherwise i.e. you
767-
# are merely stating the obvious. There are also some security
768-
# reasons in browsers, related to javascript and URL parsing
769-
# which encourage you to always set a default char set.
770-
#
771-
AddDefaultCharset ISO-8859-1
772-
773761
#
774762
# Commonly used filename extensions to character sets. You probably
775763
# want to avoid clashes with the language extensions, unless you

docs/manual/mod/core.xml

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ available</description>
139139

140140
<directivesynopsis>
141141
<name>AddDefaultCharset</name>
142-
<description>Default character set to be added for a
143-
response without an explicit character set</description>
142+
<description>Default charset parameter to be added when a response
143+
content-type is "text/plain" or "text/html"</description>
144144
<syntax>AddDefaultCharset On|Off|<var>charset</var></syntax>
145145
<default>AddDefaultCharset Off</default>
146146
<contextlist><context>server config</context>
@@ -149,21 +149,36 @@ response without an explicit character set</description>
149149
<override>FileInfo</override>
150150

151151
<usage>
152-
<p>This directive specifies the name of the character set that
153-
will be added to any response that does not have any parameter on
154-
the content type in the HTTP headers. This will override any
155-
character set specified in the body of the document via a
156-
<code>META</code> tag. A setting of <code>AddDefaultCharset
157-
Off</code> disables this
158-
functionality. <code>AddDefaultCharset On</code> enables
159-
Apache's internal default charset of <code>iso-8859-1</code> as
160-
required by the directive. You can also specify an alternate
161-
<var>charset</var> to be used. For example:</p>
152+
<p>This directive specifies a default value for the media type
153+
charset parameter (the name of a character encoding) to be added
154+
to a response if and only if the response's content-type is either
155+
"text/plain" or "text/html". This should override any charset
156+
specified in the body of the document via a <code>META</code> tag,
157+
though the exact behavior is often dependent on the user's client
158+
configuration. A setting of <code>AddDefaultCharset Off</code>
159+
disables this functionality. <code>AddDefaultCharset On</code> enables
160+
a default charset of <code>iso-8859-1</code>. Any other value is assumed
161+
to be the <var>charset</var> to be used, which should be one of the
162+
<a href="http://www.iana.org/assignments/character-sets">IANA registered
163+
charset values</a> for use in MIME media types.
164+
For example:</p>
162165

163166
<example>
164167
AddDefaultCharset utf-8
165168
</example>
169+
170+
<p><code>AddDefaultCharset</code> should only be used when all
171+
of the text resources to which it applies are known to be in that
172+
character encoding and it is too inconvenient to label their charset
173+
individually. One such example is to add the charset parameter
174+
to resources containing generated content, such as legacy CGI
175+
scripts, that might be vulnerable to cross-site scripting attacks
176+
due to user-provided data being included in the output. Note, however,
177+
that a better solution is to just fix (or delete) those scripts, since
178+
setting a default charset does not protect users that have enabled
179+
the "auto-detect character encoding" feature on their browser.</p>
166180
</usage>
181+
<seealso><directive module="mod_mime">AddCharset</directive></seealso>
167182
</directivesynopsis>
168183

169184
<directivesynopsis>

docs/manual/mod/mod_mime.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ charset</description>
235235
<usage>
236236
<p>The <directive>AddCharset</directive> directive maps the given
237237
filename extensions to the specified content charset. <var>charset</var>
238-
is the MIME charset parameter of filenames containing
238+
is the <a href="http://www.iana.org/assignments/character-sets">MIME
239+
charset parameter</a> of filenames containing
239240
<var>extension</var>. This mapping is added to any already in force,
240241
overriding any mappings that already exist for the same
241242
<var>extension</var>.</p>

0 commit comments

Comments
 (0)