diff -ur mod_dav-1.0.3-1.3.6-orig/Makefile.in mod_dav-1.0.3-1.3.6/Makefile.in --- mod_dav-1.0.3-1.3.6-orig/Makefile.in Sun Nov 4 00:00:21 2001 +++ mod_dav-1.0.3-1.3.6/Makefile.in Mon Nov 12 10:00:54 2001 @@ -27,7 +27,11 @@ mod_dav.c \ dav_lock.c \ dav_opaquelock.c \ - dav_dyn.c + dav_dyn.c \ + iconv_hook_default.c \ + iconv_hook_ja_auto.c \ + iconv_hook_mssjis.c \ + identify_encoding.c REPOS_SRCS = \ dav_fs_dbm.c \ diff -ur mod_dav-1.0.3-1.3.6-orig/configure.in mod_dav-1.0.3-1.3.6/configure.in --- mod_dav-1.0.3-1.3.6-orig/configure.in Sat Nov 3 23:48:13 2001 +++ mod_dav-1.0.3-1.3.6/configure.in Mon Nov 12 09:19:04 2001 @@ -255,6 +255,17 @@ fi # +# Check for iconv(3) support - required for l10n support +# +AC_CHECK_HEADER(iconv.h, [ + CFLAGS="$CFLAGS -DHAS_ICONV" +]) + +AC_CHECK_LIB(iconv, iconv, [ + LIBS="$LIBS -liconv" +]) + +# # Set up the various includes -- direct and via APXS # INCLUDE="$INCLUDE -I$XML_INCLUDE" --- mod_dav-1.0.3-1.3.6-orig/mod_dav.c Sun Sep 23 07:22:39 2001 +++ mod_dav-1.0.3-1.3.6/mod_dav.c Mon Nov 12 10:02:42 2001 @@ -39,6 +39,13 @@ ** so that we can keep the connection open. */ +/* +** encode conversion for filename on server with iconv() +** contributed by A.Yoshiyama, +** Debian JP Project +** NEC Solutions OSS Solution Center +*/ + #include "httpd.h" #include "http_config.h" #include "http_core.h" @@ -52,6 +59,9 @@ #include "dav_opaquelock.h" +#ifdef HAS_ICONV +#include "iconv_hook.h" +#endif /* ### what is the best way to set this? */ #define DAV_DEFAULT_PROVIDER "filesystem" @@ -79,6 +89,8 @@ dav_dyn_hooks *liveprop; dav_dyn_hooks repository; dav_dyn_hooks vsn; + + char *server_encoding; } dav_dir_conf; /* per-server configuration */ @@ -252,6 +264,8 @@ newconf->dir = DAV_INHERIT_VALUE(parent, child, dir); newconf->allow_depthinfinity = DAV_INHERIT_VALUE(parent, child, allow_depthinfinity); + newconf->server_encoding = DAV_INHERIT_VALUE(parent, child, + server_encoding); if (child->limit_xml_body != DAV_LIMIT_UNSET) newconf->limit_xml_body = child->limit_xml_body; @@ -476,6 +490,19 @@ } /* + * Command handler for DavServerEncoding directive, which is TAKE1 + */ +static const char *dav_cmd_serverencoding(cmd_parms *cmd, void *config, + char *arg1) +{ + dav_dir_conf *conf = (dav_dir_conf *) config; + + conf->server_encoding = ap_pstrdup(cmd->pool, arg1); + + return NULL; +} + +/* ** dav_error_response() ** ** Send a nice response back to the user. In most cases, Apache doesn't @@ -540,10 +567,71 @@ return dav_quote_string(p, e_uri, 0); } +#ifdef HAS_ICONV +/** + * Converts encoding of the input string. + * from mod_encoding.c by T.Yamada + * + * @param p Memory pool of apache + * @param cd Conversion descriptor, made by iconv_open(3). + * @param srcbuf Input string + * @param srclen Length of the input string. Usually strlen(srcbuf). + */ +static char * +iconv_string(request_rec *r, + iconv_hook_module *cm, iconv_t cd, char *srcbuf, size_t srclen) { + + char *outbuf, *marker; + size_t outlen; + + if (srclen == 0) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, + r->server, "iconv_string: skipping zero-length input"); + return srcbuf; + } + + /* Allocate space for conversion. Note max bloat factor is 4 of UCS-4 */ + marker = outbuf = (char *)ap_palloc(r->pool, outlen = srclen * 4 + 1); + + if (outbuf == NULL) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, + r->server, "iconv_string: no more memory"); + return NULL; + } + + /* Convert every character within input string. */ + while (srclen > 0) { + if ((*(cm->iconv))(cd, &srcbuf, &srclen, + &outbuf, &outlen) == (size_t)(-1)) { + ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, + r->server, "iconv_string: conversion error"); + return NULL; + } + } + + /* Everything done. Flush buffer/state and return result */ + (*(cm->iconv))(cd, NULL, NULL, &outbuf, &outlen); + (*(cm->iconv))(cd, NULL, NULL, NULL, NULL); + + *outbuf = '\0'; + + return marker; +} +#endif + static void dav_send_multistatus(request_rec *r, int status, dav_response *first, array_header *namespaces) { +#ifdef HAS_ICONV + iconv_hook_module *cm = NULL; /* conversion module */ + iconv_t cd = (iconv_t)-1; + int i; +#endif + dav_dir_conf *conf; + + conf = ap_get_module_config(r->per_dir_config, &dav_module); + /* Set the correct status and Content-Type */ r->status = status; r->content_type = DAV_XML_CONTENT_TYPE; @@ -570,8 +658,20 @@ /* ap_rputc('>', r); */ ap_rputs(">" DEBUG_CR, r); +#ifdef HAS_ICONV + if (conf->server_encoding) { + /* pick appropriate converter module */ + for (i = 0 ; iconv_hook_module_init[i] ; i++) { + if ((cm = (*iconv_hook_module_init[i])()) && + (cd = (*(cm->iconv_open))("UTF-8", conf->server_encoding)) != (iconv_t)(-1)) + break; + } + } +#endif + for (; first != NULL; first = first->next) { dav_text *t; + char *buff = NULL; if (first->propresult.xmlns == NULL) { ap_rputs("", r); @@ -585,7 +685,15 @@ } ap_rputs(DEBUG_CR "", r); - ap_rputs(dav_xml_escape_uri(r->pool, first->href), r); +#ifdef HAS_ICONV + if ( (cd != (iconv_t)(-1)) && + (buff = iconv_string(r, cm, cd, strdup(first->href), strlen(first->href)) ) != NULL ) + ap_rputs(dav_xml_escape_uri(r->pool, (const char *)buff), r); + else + ap_rputs(dav_xml_escape_uri(r->pool, first->href), r); +#else + ap_rputs(dav_xml_escape_uri(r->pool, first->href), r); +#endif ap_rputs("" DEBUG_CR, r); if (first->propresult.propstats == NULL) { @@ -616,6 +724,11 @@ ap_rputs("" DEBUG_CR, r); +#ifdef HAS_ICONV + if (cd != (iconv_t)(-1)) + (*(cm->iconv_close))(cd); +#endif + /* Done with sending and the timeout. */ ap_kill_timeout(r); } @@ -3336,6 +3449,14 @@ ACCESS_CONF|RSRC_CONF, /* per directory/location, or per server */ TAKE1, "Limit (in bytes) on maximum size of an XML-based request body" + }, + { + "DavServerEncoding", + dav_cmd_serverencoding, + NULL, + ACCESS_CONF|RSRC_CONF, /* per directory/location, or per server */ + TAKE1, + "Character encoding for server-side filesystem (default: UTF-8)." }, { NULL } };