On Thu, Feb 01, 2007 at 11:13:38AM -0600, William A. Rowe, Jr. wrote: > Dr. Peter Poeml wrote: > > On Thu, Feb 01, 2007 at 10:59:46 +0000, Joe Orton wrote: > >> On Wed, Jan 31, 2007 at 09:45:12PM +0100, Dr. Peter Poeml wrote: > >>> Users have a problem with directory listings generated by mod_autoindex: > >>> It is not possible to control the character setting which which the > >>> response is marked. > >> AddDefaultCharset does allow this already as you mention in the bug. > >> Can't users who insist on using filenames using one encoding and file > >> content using another simply use: > >> > >> AddDefaultCharset UTF-8 > >> AddCharset ISO-8859-1 .html > >> > >> or similar? > > > > I don't think so, because it means > > 1) that all .html files would need to be ISO-8859-1 > > 2) you cannot have files with charset=somethingelse anymore > > 3) all non-html files would need to be UTF-8 then, unless you add > > AddCharset directives for all of them... > > And you can't match by name. I'm reviewing the patch, but I'll already > offer a +1 on the concept.
On Thu, Feb 01, 2007 at 10:01:52PM +0100, Ruediger Pluem wrote: > In the general case I agree with Joe that if things can be done with existing > directives / code, no new directives / code should be added, but this case > here > is different. > > I think it is the ultimate duty of the content generator to set the correct > content type / encoding. So in this case this would be mod_autoindex. Whether > mod_autoindex detects this automatically or has a directive to set this is > another > story. Currently I would be in favour of a directive provided that there is > no reliable and performant autodetection mechanism. > > From my point of view AddDefaultCharset and AddCharset should be used to > > - configure the "core content generator" of httpd (serving static files) > - help fixing broken content generators who cannot set the encoding correctly > by themselves > > So +1 on the general concept. Cool. Here is the patch against trunk, with documentation added. I hope I got the way of patching the documentation right. A review would be very much appreciated. Thanks, Peter -- SUSE LINUX Products GmbH Bug, bogey, bugbear, bugaboo: Research & Development A malevolent monster (not true?); Some mischief microbic; What makes someone phobic; The work one does not want to do. From: Chris Young (The Omnificent English Dictionary In Limerick Form)
Index: docs/manual/mod/mod_autoindex.xml =================================================================== --- docs/manual/mod/mod_autoindex.xml (revision 520782) +++ docs/manual/mod/mod_autoindex.xml (working copy) @@ -263,6 +263,46 @@ </directivesynopsis> <directivesynopsis> +<name>AddDirectoryIndexCharset</name> +<description>Alternate character set of filenames in generated directory +index</description> +<syntax>AddDirectoryIndexCharset <var>charset</var></syntax> +<default>utf-8</default> +<contextlist><context>server config</context><context>virtual host</context> +<context>directory</context><context>.htaccess</context> +</contextlist> +<override>Indexes</override> + +<usage> + <p>The <directive>AddDirectoryIndexCharset</directive> directive + specifies the character set in which filenames are encoded, so that + the generated directory index can be correctly displayed in a + browser.</p> + + <p>To convey this information, Apache sends a + <code>Content-Language</code> header, to specify the language that + the document is in, and appends additional information onto the + <code>Content-Type</code> header to indicate the particular + character set that should be used to correctly render the + information:</p> + + <example> + Content-Type: text/html; charset=utf-8 + </example> + + <p>If filenames are not encoded in utf-8, you may specify an alternate + character set with this directive. The <code>charset</code> is the + name of the particular + <a href="http://www.iana.org/assignments/character-sets">character + set</a>which should be used.</p> + + <example><title>Example</title> + AddDirectoryIndexCharset iso-8859-1 + </example> +</usage> +</directivesynopsis> + +<directivesynopsis> <name>AddDescription</name> <description>Description to display for a file</description> <syntax>AddDescription <var>string file</var> [<var>file</var>] ...</syntax> Index: docs/manual/convenience.map =================================================================== --- docs/manual/convenience.map (revision 520782) +++ docs/manual/convenience.map (working copy) @@ -17,6 +17,7 @@ addcharset mod/mod_mime.html#addcharset adddefaultcharset mod/core.html#adddefaultcharset adddescription mod/mod_autoindex.html#adddescription +adddirectoryindexcharset mod/mod_autoindex.html#adddirectoryindexcharset addencoding mod/mod_mime.html#addencoding addhandler mod/mod_mime.html#addhandler addicon mod/mod_autoindex.html#addicon Index: modules/generators/mod_autoindex.c =================================================================== --- modules/generators/mod_autoindex.c (revision 520782) +++ modules/generators/mod_autoindex.c (working copy) @@ -130,6 +130,7 @@ int icon_height; char default_keyid; char default_direction; + char *fs_charset; apr_array_header_t *icon_list; apr_array_header_t *alt_list; @@ -556,6 +557,9 @@ AP_INIT_ITERATE2("AddAltByEncoding", add_alt, BY_ENCODING, DIR_CMD_PERMS, "alternate descriptive text followed by one or more " "content encodings"), + AP_INIT_TAKE1("AddDirectoryIndexCharset", ap_set_string_slot, + (void *)APR_OFFSETOF(autoindex_config_rec, fs_charset), + DIR_CMD_PERMS, "alternative encoding of filenames, if not utf-8"), AP_INIT_TAKE_ARGV("IndexOptions", add_opts, NULL, DIR_CMD_PERMS, "one or more index options [+|-][]"), AP_INIT_TAKE2("IndexOrderDefault", set_default_order, NULL, DIR_CMD_PERMS, @@ -617,6 +621,8 @@ : base->default_icon; new->style_sheet = add->style_sheet ? add->style_sheet : base->style_sheet; + new->fs_charset = add->fs_charset ? add->fs_charset + : base->fs_charset; new->icon_height = add->icon_height ? add->icon_height : base->icon_height; new->icon_width = add->icon_width ? add->icon_width : base->icon_width; @@ -1978,11 +1984,15 @@ return HTTP_FORBIDDEN; } -#if APR_HAS_UNICODE_FS - ap_set_content_type(r, "text/html;charset=utf-8"); -#else - ap_set_content_type(r, "text/html"); -#endif + if (autoindex_conf->fs_charset != NULL) { + ap_set_content_type(r, apr_pstrcat(r->pool, + "text/html;charset=", + autoindex_conf->fs_charset, + NULL)); + } else { + ap_set_content_type(r, "text/html;charset=utf-8"); + } + if (autoindex_opts & TRACK_MODIFIED) { ap_update_mtime(r, r->finfo.mtime); ap_set_last_modified(r);
pgp8NK9apioff.pgp
Description: PGP signature