On Sun, 30 Dec 2007 17:34:50 -0600
"William A. Rowe, Jr." <[EMAIL PROTECTED]> wrote:
> > Any objection to adding the attached (or equivalent) patch?
> > That would fix the regression the original introduces.
>
> Quick comments, _ls_ is fuzzy - call it _list_ (or _nlst_ ;-)
> Inheritance/default is broken in your config suggestion, you don't
> have a fallback, but assigning a default value in create_conf would
> hinder determining when to inherit vs. when to override.
Agreed. In fact I'd already fixed that when you replied (it's trivial).
> And third,
> this patch was already cleanly written and available, in fact ...
The patch you just committed is IMHO bloated and ugly.
I don't think this should need to touch mod_proxy or ap_mmn,
especially given that most proxy users won't use mod_proxy_ftp at all.
I attach a revised patch that fixes inheritance.
--
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,42 @@
ap_register_output_filter("PROXY_SEND_DIR", proxy_send_dir_filter,
NULL, AP_FTYPE_RESOURCE);
}
+const char *const default_charset = "ISO-8859-1";
+static void *proxy_ftp_merge(apr_pool_t *p, void *BASE, void *ADD)
+{
+ proxy_ftp_cfg *base = BASE;
+ proxy_ftp_cfg *add = ADD;
+ proxy_ftp_cfg *conf = apr_palloc(p, sizeof(proxy_ftp_cfg));
+ conf->charset = (add->charset == default_charset) ? base->charset
+ : add->charset;
+ return conf;
+}
+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 = default_charset;
+ 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 */
- NULL, /* merge per-server config structures */
- NULL, /* command apr_table_t */
+ proxy_ftp_config, /* create per-server config structure */
+ proxy_ftp_merge, /* merge per-server config structures */
+ proxy_ftp_cmds, /* command apr_table_t */
ap_proxy_ftp_register_hook /* register hooks */
};