On Sun, 30 Dec 2007 09:27:48 -0600
"William A. Rowe, Jr." <[EMAIL PROTECTED]> wrote:
> Since FTP doesn't provide us a clue of what flavor is which, for the
> purpose of a proxy ftp representation, we'll be adding a directive
> that you can apply site-by-site. Or globally, if you are convinced
> that your FTP sites are mostly/nearly all utf8. That's fine.
Any objection to adding the attached (or equivalent) patch?
That would fix the regression the original introduces.
Oh, yes, here's why it's a regression. For clients that default to
ISO-8859-1, the patch is a no-op. For a client that guesses, and
guesses right, it may cease to work where it worked before. Users
who get hit by that will see a regression, and the least we can do
is make it fixable for them.
--
Nick Kew
Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/
Index: modules/proxy/mod_proxy_ftp.c
===================================================================
--- modules/proxy/mod_proxy_ftp.c (revision 607444)
+++ modules/proxy/mod_proxy_ftp.c (working copy)
@@ -34,6 +34,9 @@
*/
#define USE_MDTM
+typedef struct {
+ const char *charset;
+} proxy_ftp_cfg;
module AP_MODULE_DECLARE_DATA proxy_ftp_module;
@@ -1691,7 +1694,10 @@
/* set content-type */
if (dirlisting) {
- ap_set_content_type(r, "text/html; charset=ISO-8859-1");
+ proxy_ftp_cfg *cfg = ap_get_module_config(r->server->module_config,
+ &proxy_ftp_module);
+ ap_set_content_type(r, apr_psprintf(r->pool, "text/html; charset=%s",
+ cfg->charset));
}
else {
if (r->content_type) {
@@ -1904,13 +1910,32 @@
ap_register_output_filter("PROXY_SEND_DIR", proxy_send_dir_filter,
NULL, AP_FTYPE_RESOURCE);
}
+static void *proxy_ftp_config(apr_pool_t *p, server_rec *s)
+{
+ proxy_ftp_cfg *conf = apr_palloc(p, sizeof(proxy_ftp_cfg));
+ conf->charset = "ISO-8859-1";
+ return conf;
+}
+static const char *proxy_ftp_ls_charset(cmd_parms *cmd, void *cfg,
+ const char *charset)
+{
+ proxy_ftp_cfg *conf = ap_get_module_config(cmd->server->module_config,
+ &proxy_ftp_module);
+ conf->charset = charset;
+ return NULL;
+}
+static const command_rec proxy_ftp_cmds[] = {
+ AP_INIT_TAKE1("ProxyFTPDirListCharset", proxy_ftp_ls_charset, NULL,
+ RSRC_CONF, "Character encoding for FTP listings"),
+ { NULL }
+};
module AP_MODULE_DECLARE_DATA proxy_ftp_module = {
STANDARD20_MODULE_STUFF,
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
+ proxy_ftp_config, /* create per-server config structure */
NULL, /* merge per-server config structures */
- NULL, /* command apr_table_t */
+ proxy_ftp_cmds, /* command apr_table_t */
ap_proxy_ftp_register_hook /* register hooks */
};